title: PHP Form Value Submit Query
body: <p>I’m hoping this is a simple thing I’m missing or not doing properly.</p>
  
  <p>It relates to posting two results from 1 submit button on a form.</p>
  
  <p>Without sending the mass of code, here’s the crux:
  (It’s a series of submit buttons in a table)</p>
  
  <pre><code>&lt;td&gt;&lt;input type=\"hidden\" name=\"query\" value=\"$query1\"&gt;&lt;input type=\"submit\"       name=\"Submitano\" value='$aa'&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type=\"hidden\" name=\"query\" value=\"$query2\"&gt;&lt;input type=\"submit\"  name=\"Submitano\" value='$ab'&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type=\"hidden\" name=\"query\" value=\"$query3\"&gt;&lt;input type=\"submit\" name=\"Submitano\" value='$ac'&gt;&lt;/td&gt;
  </code></pre>
  
  <p>Then on the other results page I use:</p>
  
  <pre><code>$s1=$_POST['Submitano'].$_POST['query'];
  </code></pre>
  
  <p>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)</p>
  
  <p>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?</p>
  
  <p>Hope this makes sense.</p>
  
  <p>Thanks</p>
  
  <p>Paul</p>
  
  <hr>
  
  <p>Thanks for all the comments. This is what I’m trying to do, but maybe I should do it in an entirely different way?</p>
  
  <p>Screen 1 – 3 – User chooses a variable on each page that is passed to Screen 4.</p>
  
  <p>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.</p>
  
  <p>The results of these 25 queries are stored in 25 variables $aa, $ab, etc.</p>
  
  <p>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).</p>
  
  <p>(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.)</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>However, does and answer lie in this solution somehow?</p>
  
  <p>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?</p>
  
  <p>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?</p>
  
  <p>Thanks again.</p>
  
  <p>Paul</p>