Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are updating your database with the results that you are pulling in.</p> <p>You need to update the database before you select your row:</p> <p><strong>Couple of notes:</strong> You are not setting <code>id</code> in your form (possibly make it a hidden input). The largest problem that I'm seeing is that you aren't initially setting ID (ie when there is no $_POST data).</p> <p>Additionallly, you should be using <a href="http://php.net/manual/en/book.pdo.php" rel="nofollow">PDO</a> or <a href="http://php.net/manual/en/book.mysqli.php" rel="nofollow">mysqli</a></p> <pre><code>if($_POST){ $id = $_POST['id']; $edit = $_POST['edit']; $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("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;"); } </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.
    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