Peform an update if action selected is edit
<p>I have a link <code>&lt;a href='test.php?action=edit&amp;id=$id'&gt;Edit&lt;/a&gt;</code> </p>

<p>If user clicks on this link an update form is displayed, for him/she to update </p>

<p>the <code>$action=="edit";</code></p>

<p>is the action perfomed in this case it must update, how ever its not here in the code </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'];
              $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());

ho("&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 width=50%&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>

<p>Is there a way to get this query to return a value cause now it seems to be not workng...</p>

<p>Im suspecting this line</p>

<pre><code>$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());
</code></pre>

<p>cause if I add the</p>

<pre><code>where id = '$id'
</code></pre>

<p>it ruturns You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1</p>

<p>if the is removed</p>

<pre><code>where id = $id
</code></pre>

<p>it returns "Query was empty"  I need help Ive been working on this it not working right</p>
