jquery - Error in update and insert query in php mysql -


i trying update seen(a bool in database) if seen button clicked , delete row if delete button clicked. doesn't seem work nor data(mysql_error) back. last else part works , data.

this php code :

if(isset($_post["seen"])){     $fid=$_post["id"];     $sql="update feedback set seen=1 id=$fid";     mysql_query($sql,$con);     echo mysql_error($con); } else if(isset($_post["delete"])){     $fid=$_post["id"];     $sql="delete feedback id=$fid";     mysql_query($sql,$con);     echo mysql_error($con); } else{     $sql="select * feedback";     $result=mysql_query($sql,$con);     while($row=mysql_fetch_array($result)){         $jsondata[]=$row;     }     echo json_encode($jsondata); } 

and js code:

$("#seen").click(function(){     $.post("main_php.php",{},function(data){         alert(data);     });  });  $("#delete").click(function(){     var fid = $('#id').val();     $.post("main_php.php",{id:fid},function(data){         console.log(data);     })  }); 

please tell me may wrong it!!!!

seen , delete names of buttons btw

your jquery post not setting "seen" or "delete". when php executes, falling through last else.

in jquery, set "seen" or "delete" true (or else, need set) , should good.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -