【发布时间】:2014-05-03 07:50:46
【问题描述】:
最近,我正在创建一个学校图书馆 Ser,在数据库(Newlibrary)中有三个表。 三表是 - 经济书籍,地理书籍,化学书籍 在每个表中,它都有(学生姓名)和(电话号码)。 我想创建一个糟糕的搜索引擎(下拉列表 - 使用选择表)并输入(电话 选择了哪个表) 这是代码,如何使用下拉列表选择表格(经济书籍或地理书籍或化学书籍)并输入电话以在同时选择的表格中搜索?
((index.html))
<form method="GET" action="searchtitle">
<select name="booktype" value="<?=$['booktype']?>">
<option value="" selected="selected"></option>
<option value="a">Econbooks</option>
<option value="b">Geobooks</option>
<option value="c">Chembooks</option>
</select>
<input id="inputkeyword" type="text" name="keyword" placeholder="Please enter a keyword...."/>
<input type="submit" class="keyword" value="search" />
</form>
((searchtitle.php))
<?php
$keyword = $_GET['keyword'];
$con = mysql_connect("localhost","root","password");
mysql_select_db("newlibrary");
$sql = "Select * from borrower
where Telp='$keyword' ";
$results = mysql_query($sql,$con);
if(mysql_num_rows($results) == 0) {echo "<h1>No Record Has Been Found!!</h1> ";} else {
echo "<table id='borrowertable' >
<tr>
<th>ID</th>
<th>Name</th>
<th>Tel</th>
</tr>" ;
while($row = mysql_fetch_array($results)) {
$bid = $row[0];
$Names = $row[1];
$Tel = $row[2];
echo " <tr>
<td>$bid</td>
<td>$Names</td>
<td>$Tel</td>
</tr>";
}
}
mysql_close($con);
echo "<p> <a href='index'>Back Home</a> ";
?>
怎么改?
【问题讨论】:
标签: php html mysql sql-server