duan19780629 2015-07-05 14:16
浏览 93

下拉选择选项表单和分页错误php

I have a form with a Select option, that loops and uses pagination to break it into five Select options per page.
But whenever a user selects options on several different pages, only the options selected on the last page before submitting the form are processed.
Research on this issue has been suggesting using AJAX or Javascript. Any idea, how i can go about it - if possible using php alone.

<form method="post" action="consel.php">
<?php
    $sql = "SELECT * FROM games WHERE startunix > '$nowtime' ORDER BY starttime LIMIT $offset, $rowsperpage" ;
    $retval = mysql_query($sql);
    while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
    {
        echo "<div align='center'><span class='style3'>{$row['home']} VS ".
             "{$row['away']} </span></div>".
             "<font color='#000000' size='2'>{$row['country']} | {$row['league']} | Time:{$row['starttime']} </font> <br> ".
             "<select name='gm[$row[gamecode]|$row[starttime]|$row[home]|$row[away]]' >
             <option value=''>Select option</option>
    <option value='1'>YES</option>
    <option value='2'> NO</option>
    <option value='3'>Total Goals</option>
    <option value='4'>Total </option>
    <option value='5'>Goals</option>

    </select>".
             "<hr>";
    }

    /******  building the pagination links ******/
    $range = 3;
    if ($currentpage > 1) {
    echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'>First Page |</a> ";
    $prevpage = $currentpage - 1;
    echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>Previous Page |</a> ";
    }
    for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
          if (($x > 0) && ($x <= $totalpages)) {
                if ($x == $currentpage) {
                     echo " [<b>$x</b>] ";
                } else {
                     echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
          } 
       } 
    } 

    if ($currentpage != $totalpages) {
         $nextpage = $currentpage + 1;
          echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>Next</a> ";
         echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>| Last</a> ";
    } 
    /****** end build pagination links ******/
?>
<input type="submit" name="play" value="submit" />
</form>

If not the Submit, but the Next button is selected, the expected $_POST['gm'] of the options selected on the first/earlier page(s) is lost. Only the options selected on the page, where the Submit button was selected, are processed.
But I want all the options selected on all the pages together to be processed.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 php 将rtmp协议转hls协议,无法播放
    • ¥15 miniconda安装不了
    • ¥20 python代码编写
    • ¥20 使用MPI广播数据遇到阻塞
    • ¥15 TinyMCE如何去掉自动弹出的“链接…”工具?
    • ¥15 微信支付转账凭证,如何解决
    • ¥15 在win10下使用指纹登录时,界面上的文字最后一个字产生换行现象
    • ¥20 使用AT89C51微控制器和MAX7219驱动器来实现0到99秒的秒表计数,有开始和暂停以及复位功能,下面有仿真图,请根据仿真图来设计c语言程序
    • ¥15 51单片机 双路ad同步采样
    • ¥15 使用xdocreport 生成word