一個搜索結果更加目前我的搜索腳本的作品,但它沒有這樣做,我想它做的事。目前它只返回一個搜索結果,即使應該爲搜索到的項目顯示大約20個搜索結果。我想弄清楚如何讓腳本返回應該顯示的那些缺失的結果。所以,也許這裏的專家能夠幫助:)顯示效果比用PHP
include('data.php');
//Database Connection
[email protected]_connect("$ip", "$user", "$pass")
or die(mysql_error());
//Select Database
[email protected]_select_db($db, $con)
or die(mysql_error());
$search = $_POST['search'];
$sql = mysql_query("select guid, name, staffmember, dateposted, id, admin_note from $whitelist where guid like '%$search%' or name like '%$search%' or staffmember like '%$search%' or dateposted like '%$search%' or id like '%$search%' or admin_note like '%$search%'");
while ($row = mysql_fetch_array($sql)) {
//Username
$name = $row['name'];
//GUID
$guid = $row['guid'];
//Staff Member Who Submitted
$staff = $row['staffmember'];
//ID
$id = $row['id'];
//Date Posted
$date = $row['dateposted'];
//Note From Admin
$admin = $row['admin_note'];
}
?>
<html>
<body>
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
<tr>
<!--<th class="table-header-check"><a id="toggle-all" ></a> </th>-->
<th class="table-header-repeat line-left minwidth-1"><a href="">ID</a> </th>
<th class="table-header-repeat line-left minwidth-1"><a href="">GUID</a></th>
<th class="table-header-repeat line-left"><a href="">Username</a></th>
<th class="table-header-repeat line-left"><a href="">Admin Note</a></th>
<th class="table-header-repeat line-left"><a href="">Staff Member</a></th>
<th class="table-header-repeat line-left"><a href="">Date Posted</a></th>
<th class="table-header-options line-left"><a href="">Options</a></th>
</tr>
<tr>
<td><?php echo "$id"; ?></td>
<td><?php echo "$guid"; ?></td>
<td><?php echo "$name"; ?></td>
<td><?php echo "$admin"; ?></td>
<td><?php echo "$staff"; ?></td>
<td><?php echo "$date"; ?></td>
<td class="options-width">
<?php
echo '<a href="edit.php?id=' . $row['id'] . '" title="Edit" class="icon-1 info-tooltip"></a>';
echo '<a href="delete.php?id=' . $row['id'] . '" title="Edit" class="icon-2 info-tooltip"></a>';
?>
</td>
</tr>
</table>
</body>
</html>
你提到你是第一次使用PHP。幫你一個忙,遠離'mysql_ *'函數並使用'mysqli_ *'或'PDO'來代替。請參閱:http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-function-in-php – h2ooooooo