Note that there are some explanatory texts on larger screens.

plurals
  1. PODealing with "random" POST data
    primarykey
    data
    text
    <p>I have a page that pulls 5 random rows from a table. It looks similar to the below.</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[1]' value = 'y'&gt;&lt;label for='1'&gt;Yes&lt;/label&gt; &lt;/td&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[1]' value = 'n'&gt;&lt;label for='1'&gt;No&lt;/label&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[8]' value = 'y'&gt;&lt;label for='8'&gt;Yes&lt;/label&gt; &lt;/td&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[8]' value = 'n'&gt;&lt;label for='8'&gt;No&lt;/label&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[2]' value = 'y'&gt;&lt;label for='2'&gt;Yes&lt;/label&gt; &lt;/td&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[2]' value = 'n'&gt;&lt;label for='2'&gt;No&lt;/label&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[6]' value = 'y'&gt;&lt;label for='6'&gt;Yes&lt;/label&gt; &lt;/td&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[6]' value = 'n'&gt;&lt;label for='6'&gt;No&lt;/label&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[3]' value = 'y'&gt;&lt;label for='3'&gt;Yes&lt;/label&gt; &lt;/td&gt; &lt;td&gt;&lt;input type = 'radio' name='bills[3]' value = 'n'&gt;&lt;label for='3'&gt;No&lt;/label&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>This returns an array that looks like the following,</p> <pre><code>Array ( [bills] =&gt; Array ( [6] =&gt; y [2] =&gt; n [5] =&gt; n [1] =&gt; y [8] =&gt; y ) ) </code></pre> <p>By using a <code>foreach($_POST['bills'] as $bill)</code> statement I can loop through that array, but how do I get the value of the id, and its respective answer? In the above case, 6, 2, 5, 1, 8.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload