dongri1989 2013-10-22 01:24
浏览 40

如何像搜索框一样跳转到PHP的页面部分?

Ok, so I have a simple page that displays the output of a MySQL table. The contents are large, and it is my intention for people to search through it.

The issue is that the database does not index it by highest rank, but rather by order created.

The page orders it for me, and then I use a cheap counter in a loop to rank players.

I already have the anchoring set up, you can search by Rank, SteamID, RP Name, and Wallet.

However, I need the search box. Currently, only SteamID is important.

http://www.triggergaming.net/stats.php is the page. I have one that currently works, but it isn't quite what i want. I want it to not require a page refresh. I currently use header() as my means of searching by placing that at the top of the page,

<?php if ($_POST["SteamID"]){
    header("Location: stats.php#".$_POST["SteamID"]);
exit;
}?>

The rank is stored as $count, steamid as $row[steamID], rpname as $row[rpname] and wallet as $row[wallet]

EDIT: Now that I think of it, Wallet is not a unique variable, and there can (and will) be duplicates. So I won't index that.

  • 写回答

1条回答 默认 最新

  • ds78662302 2013-10-22 02:27
    关注

    If you dont require a page refresh use javascript, jquery in order to construct anchor HTML like this:

    With Jquery

    HTML

    Search ID <input type="text" id="searchid"/>
    <input type="button" value="Search" id="search-button"/>
    

    Javascript:

    $('#search-button').on('click',function(ev){
        var steamID = $('#searchid').val();
        location.href='#'+steamID;
    });
    

    I rewrite a functional version with jquery and a little bit of data: http://jsfiddle.net/Uyt7a/1/ This actually works.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)