brandon000 Posted March 30, 2008 Share Posted March 30, 2008 Buddy ol' Pals...I need your help. I know this is probably such an easy fix but for the life of me I can't figure it out. Can you tell me what I'm missing as far as getting this to work: mysql_query("INSERT INTO product_sizes (SizeID,Size,StyleID) SELECT SizeID, Size From table_sizes Where table_sizes.SizeID=".$SizeID[$i].",".$StyleID); Everything works fine right up to the first two value inserts (SizeID,Size) but when I try adding the third variable (StyleID) ...I can't get this to insert any records. Do I have the correct syntax at the end of the statement? Just for reference here is the complete function: ========================================================== if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $StyleID=$_SESSION['StyleID']; $SizeID=$_POST['SizeID']; for( $i=0; $i < count($SizeID); $i++){ mysql_query("INSERT INTO product_sizes (SizeID,Size,StyleID) SELECT SizeID, Size From table_sizes Where table_sizes.SizeID=".$SizeID[$i].",".$StyleID); }} Link to comment https://forums.phpfreaks.com/topic/98703-i-need-help/ Share on other sites More sharing options...
leeandrew Posted March 30, 2008 Share Posted March 30, 2008 change: mysql_query("INSERT INTO product_sizes (SizeID,Size,StyleID) SELECT SizeID, Size From table_sizes Where to: mysql_query("INSERT INTO product_sizes (SizeID,Size,StyleID) SELECT SizeID,Size,StyleID From table_sizes Where Link to comment https://forums.phpfreaks.com/topic/98703-i-need-help/#findComment-505123 Share on other sites More sharing options...
brandon000 Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks for replying... StyleID is a session variable not part of a table. Are you sure this will work? Link to comment https://forums.phpfreaks.com/topic/98703-i-need-help/#findComment-505203 Share on other sites More sharing options...
brandon000 Posted March 30, 2008 Author Share Posted March 30, 2008 It works!!! mysql_query("INSERT INTO product_sizes (SizeID,Size,StyleID) SELECT SizeID, Size,".$StyleID. " From table_sizes Where table_sizes.SizeID=".$SizeID[$i]); Thanks leeandrew.... Link to comment https://forums.phpfreaks.com/topic/98703-i-need-help/#findComment-505208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.