gpt4 book ai didi

php - 用php显示多个搜索结果

转载 作者:行者123 更新时间:2023-11-29 14:12:35 26 4
gpt4 key购买 nike

目前我的搜索脚本可以工作,但它没有执行我希望它执行的操作。目前,它只返回一个搜索结果,尽管搜索到的项目应该显示大约 20 个搜索结果。我试图弄清楚如何让脚本返回那些应该显示的缺失结果。所以也许这里的专家可以提供帮助:)

include('data.php');
//Database Connection
$con=@mysql_connect("$ip", "$user", "$pass")
or die(mysql_error());

//Select Database
$dbcon=@mysql_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>

最佳答案

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'];
}

您在这里所做的事情是错误的。在循环的每次迭代中,变量都会被重新定义,它们的旧值将被删除并被新值覆盖。

关于php - 用php显示多个搜索结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13222912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com