How do you re-submit (re-POST) adding a single variable?<

liunx

Guest
I use a form to query a mySQL database. The results are put in a table. I want the user to be able to re-order the table from the table page. So I need to create a link that resubmits the data to the page BUT adds the a variable that tells the script to ORDER BY X.

It would take the form "resubmit()+orderer=atoz" or something, allowing me to use the value or orderer to re-order the data.

Is there a simple way to do this? The option to ORDER BY is already given on the initial form but I don't want users to have to go back to it to reorder the data if they then find they want to alter it.if you are already using order by then you can easily show links to order by as well.


if ($_GET['order']){
$order = $_GET['order'];
} else {
$order = "some_column_name";
}

select * from table order by $orderYes I can already do that (but I don't use the $_POST or $_GET superglobals).

But I want to REsubmit the form to the same php page. I do not want to have another page just for the reordering.

Edit- just found out how to do it:

processor_page.php?month=xxx
&country=xxx&some_criteria=xxx&order_by=orderer

Where xxxs are all the previously submitted variables and orderer is the conditional variable. I then use a series of ifs to append $query=$query . "ORDER BY whatever".
 
Back
Top