Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get the value of the radio button from the above example:</p> <ul> <li>if your form method is <code>POST</code>, then use <code>$_POST['select']</code>, </li> <li>or if method is <code>GET</code>, then use <code>$_GET['select']</code> </li> <li>or you can use <code>$_REQUEST['select']</code> for all methods. </li> </ul> <p>Remember also, your radio must be <strong>SET/checked</strong>, otherwise you will not pass the required variable at all. </p> <p>There should also be a pair of tags with type radio [one is set and one is not], to set/unset before a form submit. </p> <p>EDIT:</p> <pre><code> Radio: if ($row['tid'] == "1") { echo "Yes &lt;input type='radio' name='select' checked&gt; No &lt;input type='radio' name='select'&gt;"; } else { echo "Yes &lt;input type='radio' name='select'&gt; No &lt;input type='radio' name='select' checked &gt;"; } </code></pre> <p>So in your query it should be coded as:</p> <pre><code>$query = mysql_query("INSERT INTO disasterTbl (field, field2, field3) VALUES('$_POST["select"]', '$value', '$value')")or die(mysql_error()); or $query = mysql_query("INSERT INTO disasterTbl (field, field2, field3) VALUES('$_GET["select"]', '$value', '$value')")or die(mysql_error()); or $query = mysql_query("INSERT INTO disasterTbl (field, field2, field3) VALUES('$_REQUEST["select"]', '$value', '$value')")or die(mysql_error()); </code></pre> <p>Tip: You can monitor the values of the submitted form by a simple <code>print_r($_REQUEST);</code> and it should show the <code>name</code>, <code>age</code>, <code>select</code> contained in the array. </p> <p>EDIT: Also I noticed, your radio name is <code>select[]</code> instead of <code>select</code>, remove the brackets so it won't be treated as an array.</p>
    singulars
    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.
    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