0

我正在尝试缩小我正在玩的游戏的搜索结果。

我试图通过单击显示的特定用户来缩小搜索结果的范围。单击用户后,它需要显示该用户的所有数据库条目。

例如。

我的 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>";
  ?>

任何帮助都会很棒。

4

1 回答 1

0

您需要为用户详细信息页面设置一个链接,如下所示,

echo '<td><a href="userDetail.php?userID='.$row['id'].'">' . $row['user'] . '</a></td>';

创建一个名为的新页面userDetail.php,然后根据传递的用户 ID 触发 SELECT 查询,然后就可以了。

于 2013-03-19T08:29:38.627 回答