title: how to call mysql update query using onclick function
body: <pre><code>&lt;?php
  include_once("db.php");
  $result=mysql_query("SELECT * FROM stu WHERE receiver='DM4'"); 
  while($row=mysql_fetch_array($result)){
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;" . $row['ptype'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['source'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['letterno'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['date'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['descrip'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['receiver'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['title'] . "&lt;/td&gt;";
  echo "&lt;td&gt;&lt;a href='vex.php?uid={$row['letterno']}'  id='id' onClick='addfavourite()'&gt;.{$row['title']}.&lt;/a&gt;&lt;/td&gt;";
   //echo "&lt;td&gt;&lt;a href='update.php?id={$row['id']}'&gt;Update&lt;/a&gt;&lt;/td&gt;";
  echo"&lt;td&gt;&lt;img style='width:100px;higth:150px;' src='upload/{$row[image]}'&gt;&lt;/td&gt;";
  addfavourite();
  echo addfavourite();
  function addfavourite() {
   $ide=$_GET['uid'];
   //echo $ide;
  $sql = "SELECT * FROM stu WHERE letterno = '$ide'";
  $result = mysql_query($sql);
  $row = mysql_fetch_assoc($result);
  if($row){
  $newfav = "UPDATE stu SET open = 1 WHERE letterno = '$ide'";     
  $createfav = mysql_query($newfav);}
  else{
  $newfav = "UPDATE stu SET open = 0 WHERE letterno = '$ide'";   
  $createfav = mysql_query($newfav);}
  }
  
  }
  echo $ide;
  
  
  ?&gt;
  </code></pre>
  
  <p>This is my error code.In this code,there is a fault with mysql query statement.it is not supported with the databse. but onclick() function is working.</p>