我有一些select选项,我分页显示每页显示5个选项,这样就可以了。
<form method="post" action="sel.php">
<?php
---------------------------------
//Pagination script here
----------------------------------------
//Here, I retrieve some values from database
$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))
{
//Here, I display the select option while the above values are retrived
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.80 01 Both Team to Score (YES)'>1.90 Both Team to Score (YES)</option>
<option value='1.85 02 Both Team to Score (NO)'> 1.85 Both Team to Score (NO)</option>
<option value='1.90 03 Over2.5(Total Goals)'>1.90 Over2.5(Total Goals)</option>
<option value='1.80 04 Under 2.5(Total Goals)'>1.80 Under 2.5(Total Goals)</option>
<option value='1.35 05 Over 1.5 (Total Goals)'>1.35 Over 1.5 (Total Goals)</option>
<option value='2.60 06 Under 1.5 (Total Goals)'>2.60 Under 1.5 (Total Goals)</option>
<option value='2.05 07 Draw(First Half)'>2.05 Draw(First Half)</option>
<option value='1.55 08 Either Team Win (First Half)'>1.55 Either Team Win (First Half)</option>
<option value='3.70 09 Draw(Full Time)'>3.70 Draw(Full Time)</option>
<option value='1.20 10 Either Team Win (Full Time)'>1.20 Either Team Win (Full Time)</option>
<option value='1.90 11 Even(Total Goals)'>1.90 Even(Total Goals)</option>
<option value='1.90 12 Odd(Total Goals)'>1.90 Odd(Total Goals)</option>
</select>".
"<hr>";
}//end While
------------------------------
$range = 3;
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'>First Page |</a> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>Previous Page |</a> ";
} // end if
// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " [<b>$x</b>] ";
// if not current page...
} else {
// make it a link
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
} // end else
} // end if
} // end for
// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>Next</a> ";
// echo forward link for lastpage
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>| Last</a> ";
} // end if
-----------------------------------
?>
<br /><input type="submit" name="play" value="Calculate Bet" />
</form></div>
问题在于,如果用户在第1页上选择任意数量的选项,然后单击第2页,并在第2页上选择选项,则在第3页上不选择任何内容并继续提交表单,只选择在在表单处理页面上检索最后一个选择页面,即页面2。如何将所有页面中选择的选项值传递到表单处理页面,而不仅仅是最后一页上选择的值?
答案 0 :(得分:0)
有几种方法可以传递所选的选项。
您可以在网址中传递所选的值,例如example.com/?option=true&option2=true
并且可以检索,即使用isset()函数检查选项是否被选中
例如。 if(isset($_GET["option"])) { //do some stuffs }
或if($_GET["option"]=="true") { //do some stuffs }
上述方法存在很小的差异,得到和发布一个。
您需要在每种情况下将$_GET
更改为$_POST
其他两种方法,你可以使用我不推荐的cookie和会话