1. MySQL ์ฌ์ฉํ๊ธฐ ¶
- mysql_connect, mysql_close, mysql_query, mysql_affected_rows, mysql_num_rows, mysql_fetch_row, mysql_fetch_array
- mysql_connect ("์ ์ํ ์๋ฒ์ฃผ์", "์์ด๋", "ํจ์ค์๋");
- mysql ์ ์ ์ํ๋ค.
- mysql ์ ์ ์ํ๋ค.
- mysql_close();
- mysql ์ ์์ ๋๋๋ค.
- mysql ์ ์์ ๋๋๋ค.
- mysql_query("๋ฌธ์ฅ ๋์ ์ธ๋ฏธ์ฝ๋ก ์์ด ์คํํ ๋ช
๋ น์ด ์
๋ ฅ");
- mysql ํจ์๋ฅผ ์คํํ๋ค.
- mysql ํจ์๋ฅผ ์คํํ๋ค.
- ex) $result = mysql_db_query("zp2002","select * from addressbook order by binary name");
- $result ๋ ๋ณ์์ด๋ฆ, ์คํ๊ฒฐ๊ณผ์ identifier๋ฅผ ๋ฐ์
- $result ๋ ๋ณ์์ด๋ฆ, ์คํ๊ฒฐ๊ณผ์ identifier๋ฅผ ๋ฐ์
- mysql_affected_rows
- mysql_num_rows
- mysql_fetch_row(์คํ๊ฒฐ๊ณผ์ identifier);
- ์คํ๊ฒฐ๊ณผ์ identifier์ ๋ด์ฉ์ ๋ฐฐ์ด๋ก ์ ์ฅ
- ex) $row = mysql_fetch_array($result);
- ex) $row = mysql_fetch_array($result);
- ์คํ๊ฒฐ๊ณผ์ identifier์ ๋ด์ฉ์ ๋ฐฐ์ด๋ก ์ ์ฅ
- mysql_fetch_array(์คํ๊ฒฐ๊ณผ์ identifier);
- mysql_fetch_row ์ ํ์ฅํ
- ์คํ๊ฒฐ๊ณผ์ identifier์ ๋ด์ฉ์ field ๋ช
์ ์ฌ์ฉํ์ฌ ๋ฐฐ์ด๋ก ์ ์ฅ
- mysql_fetch_row ์ ํ์ฅํ
2. ์ฌ์ฉ์์ ¶
~cpp
์ฐธ๊ณ ๋ก ๋ค์์ ๋ช
๋ น์ด๋ค์ ๊ฐ์ ์คํ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ์ค๋ค..
1.
mysql_select_db("database1");
mysql_query("select * from table1 by order name");
2.
mysql_query("use database1");
mysql_query("select * from table1 by order name");
3.
mysql_db_query("database1", "select * from table1 by order name");
๋ค์์ ๊ฐ๋จํ๊ฒ ๋ง๋ค์ด ๋ณธ ์ฃผ์๋ก ์์ค์ด๋ค..
<!~cpp
<!--babo.php-->
<html>
<head>
<title> ์ฃผ์๋ก </title>
</head>
<body>
<table border=1 cellpadding=2>
<tr align=center> <td> ์ด๋ฆ </td> <td width=120> ์ ํ๋ฒํธ </td> </tr>
<?php
mysql_connect ("165.194.17.15", "zp2002", "์ํธ");
$result = mysql_db_query("zp2002","select * from addressbook order by binary name");
while($row = mysql_fetch_array($result)) {
echo "<tr> <td>", $row["name"], "</td><td align=center>", $row["phone"], "</td> </tr>";
}
mysql_close();
?>
</table>
<FORM method="POST" action="save.php" >
์ด๋ฆ <INPUT type="text" name="name" value="" size=10 maxlength=10>
์ ํ๋ฒํธ <INPUT type="text" name="phone" value="" size=15 maxlength=15>
<INPUT type="submit" value="์
๋ ฅ" size=5>
</FORM>
<font size=2 color=red>โป ์ด๋ฆ๊ณผ ์ ํ๋ฒํธ๋ฅผ ๋ชจ๋ ์
๋ ฅํด์ผ ์ ์ฅ์ด ๋ฉ๋๋ค.
<br> ์ด๋ฆ 10bytes, ์ ํ๋ฒํธ 15bytes ์ด๋ด๋ก ์
๋ ฅํด์ฃผ์ธ์. </font>
</body>
</html>
{{{~cpp
<php
if ($_POSTname != "" && $_POSTphone != "") {
mysql_connect("zeropage.org","zp2002","์ํธ");
mysql_select_db("zp2002");
mysql_query("insert into addressbook values('$_POSTname', '$_POSTphone')");
mysql_close();
}mysql_select_db("zp2002");
mysql_query("insert into addressbook values('$_POSTname', '$_POSTphone')");
mysql_close();
?>
<script language="javascript">window.location.replace("babo.php");</script>
}}} ์์ ์์ค๋ก ์์ฑํ ํ์ด์ง์ด๋ค. "์ฃผ์๋ก"










