【发布时间】:2013-03-19 08:23:10
【问题描述】:
我正在尝试缩小我正在玩的游戏的搜索结果。
我正在尝试通过单击显示的特定用户来缩小搜索结果的范围。单击用户后,它需要显示该用户的所有数据库条目。
例如。
我的 dbase 字段是:- Alliance, User, Might
当我搜索“联盟”时,我目前得到了该联盟中所有用户的列表
然后我想点击特定的“用户”并只显示该用户的结果
这是我目前所拥有的
<?php
mysql_connect ("localhost","my username","password") or die (mysql_error());
mysql_select_db ("my_dbase");
$term = $_POST['term'];
$data = mysql_query("select * FROM my_table WHERE alliance like '%$term%' ORDER BY type, alliance, might DESC");
echo "<table border='1' cellpadding='5'>";
echo "<tr> <th>Alliance</th> <th>User</th> <th>Might</th> </tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $data )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['alliance'] . '</td>';
echo '<td>' . $row['user'] . '</td>';
echo '<td>' . $row['might'] . '</td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
任何帮助都会很棒。
【问题讨论】:
-
将用户 ID 作为获取参数传递,然后清理获取参数,然后在查询中使用 user=get user
-
谢谢,但我是新手,没有编程背景,只是不明白,哈哈。通过阅读无数个论坛,我很幸运能走到这一步