vomitbomb Posted May 14, 2008 Share Posted May 14, 2008 I'm able to update the records using this code, but it updates all the records in the database not just the one row that I want. here is the code. //create a query $sql = "SELECT * FROM orders WHERE lname='$search'"; $result = mysql_query($sql, $conn); $row = mysql_fetch_array( $result ); // Update record $row = mysql_query("UPDATE orders SET status='2' WHERE status='1'") or die(mysql_error()); help appreciated Link to comment https://forums.phpfreaks.com/topic/105543-solved-trouble-updating-records/ Share on other sites More sharing options...
vomitbomb Posted May 14, 2008 Author Share Posted May 14, 2008 lol think I worked it out already changed status='1' to status'$row' Link to comment https://forums.phpfreaks.com/topic/105543-solved-trouble-updating-records/#findComment-540663 Share on other sites More sharing options...
vomitbomb Posted May 14, 2008 Author Share Posted May 14, 2008 ok nope, didn't work.. Link to comment https://forums.phpfreaks.com/topic/105543-solved-trouble-updating-records/#findComment-540664 Share on other sites More sharing options...
haku Posted May 14, 2008 Share Posted May 14, 2008 If it is updating all records, then all records have a status that is equal to 1. You need to find a different way to identify the records you want to update. Link to comment https://forums.phpfreaks.com/topic/105543-solved-trouble-updating-records/#findComment-540666 Share on other sites More sharing options...
vomitbomb Posted May 14, 2008 Author Share Posted May 14, 2008 yeah mate that's what I'm asking help for. I want to only change the status for the order that is shown in the $row variable. Link to comment https://forums.phpfreaks.com/topic/105543-solved-trouble-updating-records/#findComment-540668 Share on other sites More sharing options...
haku Posted May 14, 2008 Share Posted May 14, 2008 "UPDATE orders SET status='2' WHERE lname='$search'" Link to comment https://forums.phpfreaks.com/topic/105543-solved-trouble-updating-records/#findComment-540678 Share on other sites More sharing options...
vomitbomb Posted May 14, 2008 Author Share Posted May 14, 2008 Thanks mate, you're a legend. Link to comment https://forums.phpfreaks.com/topic/105543-solved-trouble-updating-records/#findComment-540687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.