I’m hoping this is a simple thing I’m missing or not doing properly.
It relates to posting two results from 1 submit button on a form.
Without sending the mass of code, here’s the crux: (It’s a series of submit buttons in a table)
<td><input type=\"hidden\" name=\"query\" value=\"$query1\"><input type=\"submit\" name=\"Submitano\" value='$aa'></td>
<td><input type=\"hidden\" name=\"query\" value=\"$query2\"><input type=\"submit\" name=\"Submitano\" value='$ab'></td>
<td><input type=\"hidden\" name=\"query\" value=\"$query3\"><input type=\"submit\" name=\"Submitano\" value='$ac'></td>
Then on the other results page I use:
$s1=$_POST['Submitano'].$_POST['query'];
The problem is when I click on the relevant submit button it pulls through the correct POST [‘Submitano’] that was chosen (i.e. $aa, or $ac) but it ALWAYS pulls through the last query - $query3 instead of the query that is attached to the submit. (i.e. $aa should pull through $query1, but it pulls through $query3)
I suspect it has something to do with when I click submit, it is submitting the ['Submitano'] and not the ['query'], so the next page is simply picking up the last query that was typed. If so, can anyone suggest how I can post two bits of data (one hidden, one seen) via 1 submit?
Hope this makes sense.
Thanks
Paul
Thanks for all the comments. This is what I’m trying to do, but maybe I should do it in an entirely different way?
Screen 1 – 3 – User chooses a variable on each page that is passed to Screen 4.
Screen 4 – The aforementioned 3 variables are read and fed into 25 pre-set Mysql queries and run (i.e. Query 1, Query 2, etc), but each query has a slightly different element, thus resulting in 25 different answers.
The results of these 25 queries are stored in 25 variables $aa, $ab, etc.
A form is set up that displays the results of these 25 queries, with each answer being displayed in a submit button. (i.e. where I have coded ‘Value=$aa’, it’s so the user can see the answer to that query, i.e. ‘73’ and then click on it).
(The user basically needs to see 25 different answers based on their choices in the first 3 pages, and then choose the answer they want to know more about.)
Page 5 – This page needs to know what button the user clicked, but more importantly which query they chose, but my problem is that it only feeds through the value, and not the preceding query that generated that value.
Regarding naming each one differently, I tried that but it’s how to pick it up on page 5 that’s the problem. I take it I would need 25 preset $_POST’s? The problem with that is it doesn’t like the other 24 unused $_POST’s. I even tried putting them in an elseif loop, but no joy.
However, does and answer lie in this solution somehow?
Also, a couple of people suggested an array, but as I’m not too hot on arrays I’m not sure how they would solve the problem?
If arrays are the answer, any more info on the set up or more specifically how I pull out the correct one on page 5 would be great?
Thanks again.
Paul