Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP and SQL CheckBox
    primarykey
    data
    text
    <p>I have written a form that allows for checkbox inputs in my SQL tables I have made the checkboxes as Variables. </p> <p>What i want is when i display the forms that it should show the checkbox with the value as inputted by the initial input yes or no again. </p> <pre><code>&lt;input type="checkbox" name="basic_inter" id="basic_inter" value="&lt;? echo $rows['basic_inter']; ?&gt;"&gt; </code></pre> <p>If I use it this way it doesn't show the value of the checkbox. What is best way to display the checkbox is it due to the tables being Var or is it the method I echo it back to the screen?</p> <pre><code>// Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get value of id that sent from address bar $id=$_GET['id']; // Retrieve data from database $sql="SELECT * FROM $tbl_name WHERE company_name='$query'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?&gt; &lt;form name="form" method="post" action="control_adminupdateresellered.php"&gt; &lt;input type="hidden" name="company_name" value="&lt;?=$query?&gt;" /&gt; </code></pre> <p>Then this is some of the echo code I use others not fully included as they just are text </p> <pre><code>&lt;input type="checkbox" name="basic_inter" id="basic_inter" value="&lt;? echo $rows['basic_inter']; ?&gt;"&gt; &lt;/strong&gt;&lt;/div&gt; &lt;/td&gt; &lt;td width="81"&gt;&lt;div align="right"&gt;&lt;strong&gt;LBS Add-on:&lt;br&gt; R500-00 P/M &lt;/strong&gt;&lt;/div&gt;&lt;/td&gt; &lt;td width="66"&gt;&lt;div align="left"&gt;&lt;strong&gt; &lt;input type="checkbox" name="lbs_inter" id="lbs_inter" value="&lt;? echo $rows['lbs_inter']; ?&gt;"&gt; </code></pre>
    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.
 

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