PHP-How to Pass Multiple Value In Form Field
Posted
by
Tall boY
on Stack Overflow
See other posts from Stack Overflow
or by Tall boY
Published on 2012-06-01T04:32:52Z
Indexed on
2012/06/01
4:40 UTC
Read the original article
Hit count: 168
hi i have a php based sorting method with drop down menu to sort no of rows, it is working fine. i have another sorting links to sort id & title, it is also working fine. but together they are not working fine.
what happens is that when i sort(say by title) using links, result gets sorted by title, then if i sort rows using drop down menu rows get sorted but result gets back to default of id sort.
sorting codes for id & tite is
if ($orderby == 'title' && $sortby == 'asc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=title&sort=asc'>title-asc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=title&sort=asc'>title-asc:</a></li> ";}
if ($orderby == 'title' && $sortby == 'desc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=title&sort=desc'>title-desc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=title&sort=desc'>title-desc:</a></li> ";}
if ($orderby == 'id' && $sortby == 'asc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=id&sort=asc'>id-asc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=id&sort=asc'>id-asc:</a></li> ";}
if ($orderby == 'id' && $sortby == 'desc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=id&sort=desc'>id-desc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=id&sort=desc'>id-desc:</a></li> ";}
?>
sorting codes for rows is
<form action="is-test.php" method="get">
<select name="rpp" onchange="this.form.submit()">
<option value="10" <?php if ($rowsperpage == 10) echo 'selected="selected"' ?>>10</option>
<option value="20" <?php if ($rowsperpage == 20) echo 'selected="selected"' ?>>20</option>
<option value="30" <?php if ($rowsperpage == 30) echo 'selected="selected"' ?>>30</option>
</select>
</form>
this method passes only rows per page(rpp) into url. i want it to pass order, sort& rpp. is there a way around to pass multiple values in form fields like this.
<form action="is-test.php" method="get">
<select name="rpp, order, sort" onchange="this.form.submit()">
<option value="10, $orderby, $sortby" <?php if ($rowsperpage == 10) echo 'selected="selected"' ?>>10</option>
<option value="20, $orderby, $sortby" <?php if ($rowsperpage == 20) echo 'selected="selected"' ?>>20</option>
<option value="30, $orderby, $sortby" <?php if ($rowsperpage == 30) echo 'selected="selected"' ?>>30</option>
</select>
</form>
this may seem silly but it just to give you an idea of what i am trying to implement,(i am very new to php)
please suggest any way to make this work. thanks
© Stack Overflow or respective owner