 |
|
|  |
html¿¡¼ ÀÔ·ÂÇÑ°ª DB¿¡¼ ¹Þ¾Æ¿À±â (µµ¼Á¤º¸ °Ë»ö) |
|
|
 |
9³â Àü |
book_search.html(µµ¼Á¤º¸)
book_insert.php
book_list.php
1. book_search.html(µµ¼Á¤º¸) (html¿¡¼ µµ¼Á¤º¸ ÀÔ·Â)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
<title>µµ¼°Ë»ö</title>
</head>
<body>
<p><h3>µµ¼Á¤º¸ °Ë»öÇϱâ</h3></p>
<form action='book_search.php' method='post'>
<select name='searchtype'>
<option value='title'>µµ¼¸í</option>
<option value='author'>ÀúÀÚ</option>
<option value='publisher'>ÃâÆÇ»ç</option>
<option value='isbn'>ÀϷùøÈ£</option>
</select>
<br/>
<input type='text' name='searchterm' size='40'/>
<input type='submit' value='°Ë»ö' />
</form>
</body>
</html>
----------------
2. book_search.php (html¿¡¼ ÀÔ·ÂÇÑ°ª DB¿¡¼ ºÒ·¯¿Í¼ php·Î »Ñ·ÁÁÖ±â
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
<?
$connect = mysql_connect("localhost","wooin","1234");
$db_con=mysql_select_db("wooin_db",$connect);
$query = "select * from book where ".$searchtype." like '%".$searchterm."%'";
$result = mysql_query($query, $connect);
$records = mysql_num_rows($result); // mysql_num_rows ÀÎÀÚÀÇ ·¹ÄÚµå °³¼ö¸¦ ¾Ë·ÁÁØ´Ù
$fields=mysql_num_fields($result); // mysql_num_fieldsÀÎÀÚÀÇ Çʵ尳¼ö¸¦ ¾Ë·ÁÁØ´Ù
echo "<p> °ü·Ãµµ¼¸¦ ".$records."°³ ã¾Ò½À´Ï´Ù.</p>";
$number=1;
?>
<h2> µµ¼Á¤º¸ °Ë»ö°á°ú</h2>
<table width ="800" border="1" cellspacing="0" cellpadding="5">
<tr align="center">
<td bgcolor="#cccccc">¼ø¹ø</td>
<td bgcolor="#cccccc">µµ¼¸í</td>
<td bgcolor="#cccccc">ÀúÀÚ</td>
<td bgcolor="#cccccc">ÃâÆÇ»ç</td>
<td bgcolor="#cccccc">ÁÖ¼Ò</td>
<td bgcolor="#cccccc">°¡°Ý</td>
<td bgcolor="#cccccc">ÀϷùøÈ£</td>
</tr>
<?
for($i =0; $i < $records; $i++){
echo"<tr align='center'>>";
echo"<td>$number </td>";
for($j=0; $j< $fields; $j++){
$data = mysql_result ($result, $i, $j); // ·¹ÄÚµåÀ§ ƯÁ¤À§Ä¡¿¡ ÀúÀåµÈ °ªÀ» °¡Á®¿Â´Ù
echo "<td> $data</td>";
}
echo"<tr>";
$number++;
}
mysql_close();
?> |
|
̵̧ : 553 |
̵̧
¸ñ·Ï
|
|
|  |
|