 |
|
<?php
$type=$_REQUEST['type'];
$search=$_REQUEST['search'];
require('conn_mysql.php');
if($type==""||$search==""){
?>
<center>
<form method="post" action="<? $PHP_SELF ?>">
<select name="type">
<option value="pub">Publisher</option>
<option value="title">Book Title</option>
<option value="lang">Language</option>
<option value="auth">Author</option>
</select>
<input type="text" name="search" size="30"><br><br>
<input type="submit" name="submit" value="SEARCH">
<input type="reset" name="reset" value="RESET">
</form>
</center>
<?php
}
else{
?>
<center>
<form method="post" action="<? $PHP_SELF ?>">
<select name="type">
<option value="pub">Publisher</option>
<option value="title">Book Title</option>
<option value="lang">Language</option>
<option value="auth">Author</option>
</select>
<input type="text" name="search" size="30"><br><br>
<input type="submit" name="submit" value="SEARCH">
<input type="reset" name="reset" value="RESET">
</form>
</center>
<?php
//ค้นหาตามสำนักพิมพ์
if($type=="pub"){
$sql1="select bid,title,aid,langcode,pid from book,author,language,publisher where book.aid=author.aid and book.langcode=language.langcode and
book.pid=publisher.pid and name like '".$search."'";
$query1=mysql_query($sql1,$conn) or die("Query Failer!");
if(mysql_fetch_array($query1)){
echo"<p align=\"center\"><table border=\"1\">";
echo"<tr>
<td>ID</td>
<td>TITLE</td>
<td>AUTHOR</td>
<td>Language</td>
<td>Publisher</td>
</tr>";
$result1=mysql_query($sql1,$conn) or die("Query Failer!");
while($row=mysql_fetch_array($result1)){
echo"<tr>
<td>".$row['bid']."</td>
<td>".$row['title']."</td>
<td>".$row['aid']."</td>
<td>".$row['langcode']."</td>
<td>".$row['pid']."</td>
</tr>";
}
echo"</table></p>";
}
else
echo"<p align=\"center\">ไม่พบข้อมูลที่ต้องการค้นหา!</p>";
}
//ค้นหาตามชื่อหนังสือ
else if($type=="title"){
$sql2="select bid,title,aid,langcode,pid from book,author,language,publisher where book.aid=author.aid and book.langcode=language.langcode and
book.pid=publisher.pid and title like '".$search."'";
$query2=mysql_query($sql2,$conn) or die("Query Failer!");
if(mysql_fetch_array($query2)){
echo"<p align=\"center\"><table border=\"1\">";
echo"<tr>
<td>ID</td>
<td>TITLE</td>
<td>AUTHOR</td>
<td>Language</td>
<td>Publisher</td>
</tr>";
$result=mysql_query($sql2,$conn) or die("Query Failer!");
while($row=mysql_fetch_array($result2)){
echo"<tr>
<td>".$row['bid']."</td>
<td>".$row['title']."</td>
<td>".$row['aid']."</td>
<td>".$row['langcode']."</td>
<td>".$row['pid']."</td>
</tr>";
}
echo"</table></p>";
}
else
echo"<p align=\"center\">ไม่พบข้อมูลที่ต้องการค้นหา!</p>";
}
//ค้นหาตามภาษา
else if($type=="lang"){
$sql3="select bid,title,aid,langcode,pid from book,author,language,publisher where book.aid=author.aid and book.langcode=language.langcode and
book.pid=publisher.pid and langname like '".$search."'";
$query3=mysql_query($sql3,$conn) or die("Query Failer!");
if(mysql_fetch_array($query3)){
echo"<p align=\"center\"><table border=\"1\">";
echo"<tr>
<td>ID</td>
<td>TITLE</td>
<td>AUTHOR</td>
<td>Language</td>
<td>Publisher</td>
</tr>";
$result3=mysql_query($sql3,$conn) or die("Query Failer!");
while($row=mysql_fetch_array($result3)){
echo"<tr>
<td>".$row['bid']."</td>
<td>".$row['title']."</td>
<td>".$row['aid']."</td>
<td>".$row['langcode']."</td>
<td>".$row['pid']."</td>
</tr>";
}
echo"</table></p>";
}
else
echo"<p align=\"center\">ไม่พบข้อมูลที่ต้องการค้นหา!</p>";
}
//ค้นหาตามผู้แต่ง
else if($type=="auth"){
$sql4="select bid,title,aid,langcode,pid from book,author,language,publisher where book.aid=author.aid and book.langcode=language.langcode and
book.pid=publisher.pid and firstname like '".$search."'";
$query4=mysql_query($sql4,$conn) or die("Query Failer!");
if(mysql_fetch_array($query4)){
echo"<p align=\"center\"><table border=\"1\">";
echo"<tr>
<td>ID</td>
<td>TITLE</td>
<td>AUTHOR</td>
<td>Language</td>
<td>Publisher</td>
</tr>";
$result4=mysql_query($sql4,$conn) or die("Query Failer!");
while($row=mysql_fetch_array($result4)){
echo"<tr>
<td>".$row['bid']."</td>
<td>".$row['title']."</td>
<td>".$row['aid']."</td>
<td>".$row['langcode']."</td>
<td>".$row['pid']."</td>
</tr>";
}
echo"</table></p>";
}
else
echo"<p align=\"center\">ไม่พบข้อมูลที่ต้องการค้นหา!</p>";
}
}
mysql_close($conn);
?>
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2012-02-13 20:18:47 |
By :
พี่เดช |
View :
892 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |