title: Post multiple values from database, in one Option
body: <p>I am looking to populate a drop down field with a list of names from a database, and when an option is selected from that drop down, it will post all its values in the row, belonging to that chosen option.</p>
  
  <p>This is probably hard to describe/understand, so to help illustrate, this is my table row:</p>
  
  <p><img src="https://i.stack.imgur.com/gm3Ec.png" alt="db structure"></p>
  
  <p>I then proceed to populate the dropdown, and  associate its value to whatever the selected option is posted</p>
  
  <pre><code>//////db_conx is db connection //////main_meal is table name
        &lt;form action="#" method="post"&gt;
                          &lt;?php  
                          $dropdown = $db_conx-&gt;query("SELECT * FROM main_meal") or die ("somethings broken");                       
                          while($array[] = $dropdown-&gt;fetch_object());
                          //echo '&lt;option value ="'.$record['Mname'].'"&gt;'.$record['Mname'].'"&lt;/option&gt;';                        
                          array_pop($array);                       
                          ?&gt;
  
                          &lt;select name="changeCal"&gt;
                              &lt;?php    foreach($array as $option) :?&gt;
                              &lt;!--//get chosen value in drop down, and get its calories--&gt;
                              &lt;option value="&lt;?php echo $option-&gt;calories;?&gt;"&gt;&lt;?php echo $option-&gt;Mname; ?&gt;&lt;/option&gt;
                              &lt;?php endforeach; ?&gt;
                          &lt;/select&gt;
  </code></pre>
  
  <p>This works great for one value, such as calories, in the above code, but I need more values.</p>
  
  <p>For example, if choose Healthy egg and chips, the value will post 218, as the loop only associates calories and names at the moment.</p>
  
  <p>I attempted various things, like this post:<a href="https://stackoverflow.com/questions/12791021/how-to-get-multiple-values-from-a-single-select-variable-in-html-php">How to get multiple values from a single &lt;select&gt; variable in HTML/PHP?</a></p>
  
  <p>But the foreach errors.</p>
  
  <p>How can I something similar to what I have done, but store multiple values from one chosen option?</p>
  
  <p>Thank you</p>