Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate table if user clicks edit link
    text
    copied!<p>Im trying to get my query to update upon user click This one here works but it doesnt wanna update I Says Query Empty</p> <p>I edited the code as follows</p> <pre><code> if ($action == "edit"){ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $result=mysql_query("UPDATE user SET first_name='$first_name',last_name='$last_name',email='$email' WHERE id=$id"); $sql = mysql_query($result) or die (mysql_error()); } $sql=mysql_query("select * from user where id='$id'"); while ($row=mysql_fetch_array($sql)){ $id = $row['id']; $first_name = $row['first_name']; $last_name = $row['last_name']; $email = $row['email']; echo("&lt;form name='edit' method='post' action='?action=edit'&gt;"); echo("&lt;input type='hidden' name='?action=edit'&gt;"); echo("&lt;table class=main cellspacing=0 cellpadding=5 &gt;"); echo("&lt;tr&gt;&lt;td&gt;Name: &lt;/td&gt;&lt;td align='right'&gt;&lt;input type='text' name='first_name' value='$first_name'&gt;&lt;/td&gt;&lt;/tr&gt;"); echo("&lt;tr&gt;&lt;td&gt;Surname: &lt;/td&gt;&lt;td align='right'&gt;&lt;input type='text' name='last_name' value='$last_name'&gt;&lt;/td&gt;&lt;/tr&gt;"); echo("&lt;tr&gt;&lt;td&gt;Email: &lt;/td&gt;&lt;td align='right'&gt;&lt;input type='text' name='email' value='$email'&gt;&lt;/td&gt;&lt;/tr&gt;"); echo("&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;div align='right'&gt;&lt;input type='submit'&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;"); echo("&lt;/table&gt;"); } } echo("&lt;br&gt;"); echo("&lt;/form&gt;"); </code></pre> <p>I added <code>$sql = mysql_query($result) or die (mysql_error());</code></p> <p>the above line shows what time of error the query encounted while executing... Any Ideas as to why the query is empty and wheres there is data in the table?</p> <p>This Code will run upon the clicking of this link </p> <pre><code>echo"&lt;a href='test.php?action=edit&amp;id=$id'&gt;Edit&lt;/a&gt;"; </code></pre>
 

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