How do I get 'id' from database to update a particular row? <p>I am trying to update a row which is already in database, and i am using above code for that but it gives me error as 'undefined id', so how can i do this.....please help me!!!</p> <pre><code>if(isset($_POST['sub'])) { $getid="select id from login"; $res=mysql_query($getid); $ids=$_GET[$row['id']]; $about=$_POST['desc']; $pri=$_POST['price']; $ride=$_POST['fly']; $city=$_POST['ct']; $flt=""; foreach($ride as $entry) { $flt .= $entry.","; } $ct=""; foreach($city as $entry) { $ct .= $entry.","; } $query ="UPDATE login SET rides='$flt',price=$pri,about='$about',city='$ct' WHERE id='$ids'"; $result = mysql_query($query); echo $result; if(!$result) { echo '&lt;script language="javascript"&gt;'; echo 'alert("something went Wrong...:("); location.href="edit.php"'; echo '&lt;/script&gt;'; } else { echo '&lt;script language="javascript"&gt;'; echo 'alert("successfully updated!!!"); location.href="edit.php"'; echo '&lt;/script&gt;'; } } </code></pre>