rfrunk Posted November 17, 2010 Share Posted November 17, 2010 Just need what for some of you should be easy. Trying a mod on prestashop and just need the following to work.It works fine if there is just one row of data (one product). If there are more than one the first row works fine but the second and susequent rows fail. $sql = "SELECT * FROM ps_cart_product Where id_cart = '$cartid'"; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $product_instructions = $row ['instructions']; $product_request = $row ['request']; } $db = Db::getInstance(); mysql_query("UPDATE `store`.`ps_order_detail` SET `product_instructions` = '$product_instructions',`product_request` = '$product_request' WHERE `ps_order_detail`.`id_order` = '$id_order' AND `ps_order_detail`.`product_name` like '%$product_instructions%'"); Link to comment Share on other sites More sharing options...
rocky Posted November 26, 2010 Share Posted November 26, 2010 It seems you have the curly braces in the wrong place, causing the $product_instructions and $product_request to be overwritten with each subsequent loop. Try: $sql = "SELECT * FROM ps_cart_product Where id_cart = '$cartid'"; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $product_instructions = $row ['instructions']; $product_request = $row ['request']; $db = Db::getInstance(); mysql_query("UPDATE `store`.`ps_order_detail` SET `product_instructions` = '$product_instructions',`product_request` = '$product_request' WHERE `ps_order_detail`.`id_order` = '$id_order' AND `ps_order_detail`.`product_name` like '%$product_instructions%'"); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now