donglao4370 2013-03-19 08:23
浏览 24

从搜索结果中搜索范围较窄

I am trying to narrow search results for a game I'm playing.

I am trying to narrow down my search results by clicking on a particular user that is displayed. Once the user is clicked it need to show all database entries for that user.

For example.

My dbase fields are :- Alliance, User, Might

When I search for 'Alliance', I currently get a list of all users in that alliance

I want to then click on a particular 'user' and only show the results for that user

This is what I have so far

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

Any help would be fantastic.

  • 写回答

1条回答 默认 最新

  • doubu4826 2013-03-19 08:29
    关注

    You need to set a link for user detail page as below,

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

    Create one new page called userDetail.php and just fire SELECT query according to userID passed and there you have it.

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示