Note that there are some explanatory texts on larger screens.

plurals
  1. POIf uncheck the check box delete row in my SQL table
    primarykey
    data
    text
    <p>Actually I am very new to php.. I have a task that select records from database as checkboxes checked. When I uncheck a checkbox it should delete that particular record from my database..</p> <p>My code is </p> <pre><code>&lt;?php if(isset($_POST['delete'])) { $test=$_POST['test']; $qun1=$_POST['question1']; //DB connection $CON=mysql_connect("localhost","root",""); mysql_select_db("Dbname"); if($qun1!=0 &amp;&amp; $test!=0) { foreach($qun1 as $qunestion) { echo $question; //this is for testing $query=mysql_query("delete from test_question where test_questions_id='$test' AND question_id IN ('$question') " ) or die(mysql_error()); } if($query) { echo "success"; } else { echo "No"; } } } ?&gt; </code></pre> <p>my code is working properly but if i use NOT IN in the place of IN it is not working..why?..if unchecked the records it should be delete..i already retrieve records from database as checked fields..</p> <p>My html markup:</p> <pre><code> &lt;script&gt; function fun2(ts) { $.post("ajax2.php",{qs:ts},function(data) { document.getElementById('div1').innerHTML=data }) } &lt;/script&gt; &lt;form action="somepage.php" method="post"&gt; //dynamic selection test code &lt;select name="test" id="test" onChange="fun2(this.value);"&gt; &lt;option value=""&gt;Select Test&lt;/option&gt; &lt;/select&gt; &lt;div id="div1" &gt; &lt;/div&gt; &lt;input type="submit" name="delete" value="Delete" &gt; &lt;/from&gt; </code></pre> <p>my ajax code:</p> <pre><code> &lt;?php $qs=$_REQUEST['qs']; mysql_connect("localhost","root",""); mysql_select_db("advancedge"); $sql=mysql_query("select question_id from test_question where test_questions_id='$qs'"); if($sql) { while($rec=mysql_fetch_row($sql)) { echo "&lt;input type='checkbox' name='question1[]' value='$rec[0]' checked='checked' &gt;"; } } ?&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.
    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