douliao1911 2015-01-16 02:56
浏览 18
已采纳

PHP GET的复杂问题

I have a form to enter a match number and submit via PHP GET to the url, say test.php?match=

I added arrows for ease of use (time is important for the end user) that go up one match and down one match, and they work OK as long as you don't input a number first. The arrows add the number OK and I can start from 0 and go up, but if I start on another number it works once but deletes the number from the URL (for example, navigating to test.php?match=3 and pressing right arrow displays match 4 but the URL is changed to test.php?match= )

Here is my code:

<?php
$next = $_GET["match"] + "1";
$last = $_GET["match"] - "1";
echo "<form action=\"test.php\" method=\"GET\">
    Match<br>
    <input style=\"font-size:24px;\" autofocus=\"autofocus\" type=\"number\" size=\"4\" name=\"match\" value=\"" . $_GET["match"] . "\">
    <a href=\"sql.php?match=\"><button style=\"font-size:24px;\">Show All</button></a>
    <a href=\"sql.php?match=" . $last . "\"><button style=\"font-size:24px;\"><</button></a>
    <a href=\"sql.php?match=" . $next . "\"><button style=\"font-size:24px;\">></button></a>
    <input style=\"font-size:24px;\" type=\"submit\" value=\"Submit\">
    </form>";
?>

Thanks!

  • 写回答

2条回答 默认 最新

  • dongxun7962 2015-01-16 03:11
    关注

    Try to replace your form with this:

    echo "<form action= 'test.php' method='GET'>
            Match<br>
            <input style='font-size:24px;' autofocus='autofocus' type='number' size='4' name='match' value='" . $_GET["match"] . "'>
            <a href='sql.php?match='><button style='font-size:24px;'>Show All</button></a>
            <a href='sql.php?match=" . $last . "' style = 'padding: 5px; border-radius: 5px; background: rgb(240, 240, 240); border: 1px solid silver;'><<<</a>
            <a href='sql.php?match=" . $next . "' style = 'padding: 5px; border-radius: 5px; background: rgb(240, 240, 240); border: 1px solid silver;'>>>></a>
            <input style='font-size:24px;' type='submit' value='Submit'>
            </form>";
    

    The <a> is not directing you to the link if the <button> inside it is clicked. It appears that you are clicking the <button> and not the <a>. So as a suggestion, you can style you <a> so that it may appear as a button.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集