Note that there are some explanatory texts on larger screens.

plurals
  1. POput the value of radio button and check box into database PHP
    primarykey
    data
    text
    <p>I would like to try insert the value of checkbox and radio button into my database...when I choose the option of checkbox and choose the option of radio button, the value of checkbox and radio button will recorded in the same row in database...I have 3 menu choices..each menu have 2 size options which is radio button..that's mean for each size option there should have different name right??...the name I mean is field1[]....</p> <p>this is my code</p> <p><strong>resto.php</strong> </p> <pre><code>Menu : &lt;input type="checkbox" value="Siomay" name="tile[]"&gt;Siomay &lt;br&gt; &lt;input type="radio" name="field1[]" value="4" /&gt;Small &lt;input type="radio" name="field1[]" value="5" /&gt;Large&lt;br&gt; &lt;input type="checkbox" value="Batagor" name="tile[]"&gt;Batagor &lt;br&gt; &lt;input type="radio" name="field2[]" value="4" /&gt;Small &lt;input type="radio" name="field2[]" value="5" /&gt;Large&lt;br&gt; &lt;input type="checkbox" value="Pempek" name="tile[]"&gt;Pempek&lt;br&gt; &lt;input type="radio" name="field3[]" value="4" /&gt;Small &lt;input type="radio" name="field3[]" value="5" /&gt;Large&lt;br&gt; &lt;input name="confirm" type=submit id="confirm" value='Confirm'&gt; &lt;/form&gt; </code></pre> <p><strong>menu2.php</strong></p> <pre><code>&lt;?php $con = mysql_connect("localhost","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("project1", $con); $Tile = mysql_real_escape_string($_POST['tile']); $Field = mysql_real_escape_string($_POST['field1']); if ( !empty($Tile) &amp;&amp; !empty($Field) ) { $insert="INSERT INTO menu(name, price) VALUES ('$Tile','$Field')"; if (!mysql_query($insert, $con)) { die('Error: ' . mysql_error()); } echo "1 record added"; } else echo "Please select at least 1 menu."; mysql_close($con) ?&gt; </code></pre>
    singulars
    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.
 

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