waijs Posted December 5, 2008 Share Posted December 5, 2008 I have the php/mysql code below: It is supposed to update a table column(parentidf) to the values of another column(productid) in the same table WHERE a colum(originalid) in the same table IS EQUAL TO values of column(productid). Guys,am new to php/msql;pls help me out! <html> <head><title>Update product group table</title> </head> <body> <?php //a file for the database select and connection include('incsec/connect.inc.php'); $sql = "SELECT * FROM tblproductgroups"; $result = mysql_query($sql); while($myrow = mysql_fetch_row($result)) { //Get ParentIDF $parentgroupidf = $myrow['parentgroupidf']; $productgroupid = $myrow['productgroupid']; //query to find the original id where it is equal to the parentidf $sql2 = "SELECT * FROM tblproductgroups WHERE originalid = $parentgroupidf ;"; $result2 = mysql_query($sql2); $sql3 = "UPDATE tblproductgroups SET parentgroupidf = $productgroupid ;"; $result3 = mysql_query($sql3); } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/135614-help-me-out-pls-asp/ Share on other sites More sharing options...
fenway Posted December 5, 2008 Share Posted December 5, 2008 Yikes... an UPDATE with no WHERE clause.... Link to comment https://forums.phpfreaks.com/topic/135614-help-me-out-pls-asp/#findComment-706706 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.