TCombs Posted April 9, 2011 Share Posted April 9, 2011 I've used a lot of solutions from this site, however, this is my first post, so go easy on me :-) I've created a product form the successfully INSERTS data to a mysql table. I can successfully query the data so that product information can be updated. When I click submit to UPDATE the rows, everything updates except for 2 fields that are arrays. Here is my product form that populates data to be edited. <?php session_start(); require("config.php"); require("db.php"); require("functions.php"); if(isset($_SESSION['SESS_ADMINLOGGEDIN']) == FALSE) { header("Location: " . $config_basedir); } if(isset($_GET['func']) == TRUE) { if($_GET['func'] != "conf") { header("Location: " . $config_basedir); } $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); header("Location: " . $config_basedir . "adminedit.php"); } else { require("header.php"); $sql = "SELECT * FROM products WHERE id = " . $_GET['id'] . ";"; $query = mysql_query($sql); while ($prodrow = mysql_fetch_array($query)){ $id = $prodrow['id']; $active=$prodrow['active']; $cat_id=$prodrow['cat_id']; $name=$prodrow['name']; $description=$prodrow['description']; $details=$prodrow['details']; $price=$prodrow['price']; $price2=$prodrow['price2']; $price3=$prodrow['price3']; $price4=$prodrow['price4']; $price5=$prodrow['price5']; $price6=$prodrow['price6']; $minimum=$prodrow['minimum']; $price7=$prodrow['price7']; $price8=$prodrow['price8']; $price9=$prodrow['price9']; $image=$prodrow['image']; } ?> <form action="adminprodupdate.php" method="post"> <table width="500" border="1" cellpadding="10"> <tr> <td>ID:</td> <td><input type="hidden" value="<? echo $id; ?>" name="id" /></td> </tr> <tr> <td>Active:</td> <td><input name="active" type="radio" value="0" <?php echo ($active=='0')? 'checked':'';?> />Yes<br /> <input name="active" type="radio" value="1" <?php echo ($active=='1')? 'checked':'';?> />No</td> </tr> <tr> <td>Category:</td> <td><input name="cat_id" type="radio" value="1" <?php echo ($cat_id=='1')? 'checked':'';?> />Hats<br /> <input name="cat_id" type="radio" value="2" <?php echo ($cat_id=='2')? 'checked':'';?> />Shirts<br /> <input name="cat_id" type="radio" value="3" <?php echo ($cat_id=='3')? 'checked':'';?> />Promotional Items</td> </tr> <tr> <td>Product ID: </td> <td><input type="text" name="name" value="<? echo $name; ?>"></td> </tr> <tr> <td>Short Description: </td> <td><input type="text" name="description" value="<? echo $description; ?>"></td> </tr> <tr> <td>Details:</td> <td><textarea name="details" cols="50" rows="10" ><? echo $details; ?></textarea></td> </tr> <tr> <td>Price for S-XL:<br /> <br /><strong><div id="redfont">**Shirts**<br />&<br />**Hats**</div></strong></td> <td>1-23: <input type="text" name="price" value="<? echo $price; ?>"><br><br> 24-47: <input type="text" name="price2" value="<? echo $price2; ?>"><br><br> 48+: <input type="text" name="price3" value="<? echo $price3; ?>"><br><br> </td> </tr> <tr> <td>Price for 2XL - 5XL:<br /> <br /><strong><div id="redfont">**Shirts ONLY!**</div></strong></td> <td>1-23: <input type="text" name="price4" value="<? echo $price4; ?>"><br><br> 24-47: <input type="text" name="price5" value="<? echo $price5; ?>"><br><br> 48+: <input type="text" name="price6" value="<? echo $price6; ?>"><br><br> </td> </tr> <tr> <td>Minimum QTY: </td> <td><input type="text" name="minimum" value="<? echo $minimum; ?>"></td> </tr> <tr> <td>Sizes:</td> <td><? echo ''; $result = mysql_query("SELECT * FROM sizes"); while ($row = mysql_fetch_assoc($result)) { $selected = ''; $result2 = mysql_query("SELECT * FROM productoptions WHERE productid = '" . $_GET['id'] . "' AND sizeid = '" . $row['id'] . "'"); if ($row2 = mysql_fetch_assoc($result2)) { $selected = 'checked '; } echo '<input type="checkbox" name="size[]" value="' . $row['id'] . '" ' . $selected . '/> ' . $row['size'] . '<br />'; } ?> </td> </tr> <tr> <td>Colors:</td> <td><? $result = mysql_query("SELECT * FROM colors"); while ($row = mysql_fetch_assoc($result)) { $selected = ''; $result2 = mysql_query("SELECT * FROM productoptions WHERE productid = '" . $_GET['id'] . "' AND colorid = '" . $row['id'] . "'"); if ($row2 = mysql_fetch_assoc($result2)) { $selected = 'checked '; } echo '<input type="checkbox" name="color[]" value="' . $row['id'] . '" ' . $selected . '/> ' . $row['color'] . '<br />'; } ?> </td> </tr> <tr> <td> </td> <td><input type="Submit" value="Update this product"></td> </tr> </form> </table> <?php } require("footer.php"); ?> Here is my script: <?php include("config.php"); include("db.php"); $id=$_POST['id']; $active=$_POST['active']; $cat_id=$_POST['cat_id']; $name=$_POST['name']; $description=$_POST['description']; $details=$_POST['details']; $price=$_POST['price']; $price2=$_POST['price2']; $price3=$_POST['price3']; $price4=$_POST['price4']; $price5=$_POST['price5']; $price6=$_POST['price6']; $minimum=$_POST['minimum']; $arrsizes = $_POST['size']; $arrcolors = $_POST['color']; $image=$_POST['image']; $sql="UPDATE products SET active = '$active', cat_id = '$cat_id', name = '$name', description = '$description', details = '$details', price = '$price', price2 = '$price2', price3 = '$price3', price4 = '$price4', price5 = '$price5', price6 = '$price6', minimum = '$minimum', image = '$image' WHERE id = '$id'"; $result = mysql_query("SELECT id FROM products ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $productid = $row['id']; } foreach ($arrsizes as $sizevalue) { foreach ($arrcolors as $colorvalue) { $sql2="UPDATE productoptions SET sizeid = '$sizevalue', colorid = '$colorvalue' WHERE productid='$id' "; } } mysql_query($sql) or die ("Error: ".mysql_error()); mysql_query($sql2) or die ("Error: ".mysql_error()); echo $sql; echo $sql2; header("Location: " . $config_basedir . "adminhome.php"); ?> And here is what is echo'd after submit: UPDATE products SET active = '0', cat_id = '2', name = 'Test Edit Prod', description = 'just a simple test', details = 'just a simple testjust a simple testjust a simple testjust a simple testjust a simple testjust a simple test', price = '1', price2 = '2', price3 = '3', price4 = '4', price5 = '5', price6 = '6', minimum = '127', image = '' WHERE id = '41'UPDATE productoptions SET sizeid = '6', colorid = '5' WHERE productid='41' This part of the code: UPDATE productoptions SET sizeid = '6', colorid = '5' WHERE productid='41' , is supposed to be updating sizes and colors, however, it is only updating the last size/color selected in the check box. Thanks in advance for any support! Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/ Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 Sorry, don't mind me. Maybe if you post how the size/color rows are supposed to work I could figure out how to update them. If I understand them correctly, you would have to delete them all and then reinsert the ones that are checked. Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199078 Share on other sites More sharing options...
kenrbnsn Posted April 9, 2011 Share Posted April 9, 2011 Please post the form that is being used by this script. Ken Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199079 Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 Here's what might work: mysql_query("DELETE FROM productoptions WHERE productid='$id'"); foreach ($arrsizes as $sizevalue) { foreach ($arrcolors as $colorvalue) { $sql2 = "INSERT INTO productoptions (sizeid, colorid) VALUES ($sizevalue, $colorvalue) WHERE productid = '$id'"; mysql_query($sql2) or die("Error: ".mysql_error()); } } Make sure to get rid of the other $sql2 query under this code. @kenrbnsn: it's in his first post in the first block. Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199080 Share on other sites More sharing options...
TCombs Posted April 9, 2011 Author Share Posted April 9, 2011 Thanks for the responses...Hope this is a better explanation. The products form has a lot of fields, but the important ones are sizes and colors. For example - The store owner creates a new product, in this case it's a Shirt. The shirt is available in Small, Medium, Large, XL, XXL, XXXL , and can be purchased in Green, Blue, Red, Orange, Black, and White. (The form has check boxes for sizes - small - 5XL , and a list of 20 colors to choose from). After the Store owner creates the shirt, he decides he wants make this shirt available in only Small - XXL , and in colors Black or White. At this point, he will click the link "EDIT PRODUCT, which will open up this file: adminprodupdate.php <?php Print_r($_Post); include("config.php"); include("db.php"); $id=$_POST['id']; $active=$_POST['active']; $cat_id=$_POST['cat_id']; $name=$_POST['name']; $description=$_POST['description']; $details=$_POST['details']; $price=$_POST['price']; $price2=$_POST['price2']; $price3=$_POST['price3']; $price4=$_POST['price4']; $price5=$_POST['price5']; $price6=$_POST['price6']; $minimum=$_POST['minimum']; $arrsizes = $_POST['size']; $arrcolors = $_POST['color']; $image=$_POST['image']; $sql="UPDATE products SET active = '$active', cat_id = '$cat_id', name = '$name', description = '$description', details = '$details', price = '$price', price2 = '$price2', price3 = '$price3', price4 = '$price4', price5 = '$price5', price6 = '$price6', minimum = '$minimum', image = '$image' WHERE id = '$id'"; $result = mysql_query("SELECT id FROM products ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $productid = $row['id']; } foreach ($arrsizes as $sizevalue) { foreach ($arrcolors as $colorvalue) { $sql2="UPDATE productoptions SET sizeid = '$sizevalue', colorid = '$colorvalue' WHERE productid='$id' "; } } mysql_query($sql) or die ("Error: ".mysql_error()); mysql_query($sql2) or die ("Error: ".mysql_error()); echo $sql; echo $sql2; header("Location: " . $config_basedir . "adminhome.php"); ?> At this point, the store owner sees all of the information available for this product, so he scrolls down the form, unchecks the boxes for all colors except Black and White, and unchecks all the sizes except for Small - XLarge. When he clicks "Update this product", the adminedit.php file processes the changes. here is the adminedit.php file <?php session_start(); require("config.php"); require("db.php"); require("functions.php"); if(isset($_SESSION['SESS_ADMINLOGGEDIN']) == FALSE) { header("Location: " . $config_basedir); } if(isset($_GET['func']) == TRUE) { if($_GET['func'] != "conf") { header("Location: " . $config_basedir); } $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); header("Location: " . $config_basedir . "adminedit.php"); } else { require("header.php"); $sql = "SELECT * FROM products WHERE id = " . $_GET['id'] . ";"; $query = mysql_query($sql); while ($prodrow = mysql_fetch_array($query)){ $id = $prodrow['id']; $active=$prodrow['active']; $cat_id=$prodrow['cat_id']; $name=$prodrow['name']; $description=$prodrow['description']; $details=$prodrow['details']; $price=$prodrow['price']; $price2=$prodrow['price2']; $price3=$prodrow['price3']; $price4=$prodrow['price4']; $price5=$prodrow['price5']; $price6=$prodrow['price6']; $minimum=$prodrow['minimum']; $price7=$prodrow['price7']; $price8=$prodrow['price8']; $price9=$prodrow['price9']; $image=$prodrow['image']; } ?> <form action="adminprodupdate.php" method="post"> <table width="500" border="1" cellpadding="10"> <tr> <td>ID:</td> <td><input type="hidden" value="<? echo $id; ?>" name="id" /></td> </tr> <tr> <td>Active:</td> <td><input name="active" type="radio" value="0" <?php echo ($active=='0')? 'checked':'';?> />Yes<br /> <input name="active" type="radio" value="1" <?php echo ($active=='1')? 'checked':'';?> />No</td> </tr> <tr> <td>Category:</td> <td><input name="cat_id" type="radio" value="1" <?php echo ($cat_id=='1')? 'checked':'';?> />Hats<br /> <input name="cat_id" type="radio" value="2" <?php echo ($cat_id=='2')? 'checked':'';?> />Shirts<br /> <input name="cat_id" type="radio" value="3" <?php echo ($cat_id=='3')? 'checked':'';?> />Promotional Items</td> </tr> <tr> <td>Product ID: </td> <td><input type="text" name="name" value="<? echo $name; ?>"></td> </tr> <tr> <td>Short Description: </td> <td><input type="text" name="description" value="<? echo $description; ?>"></td> </tr> <tr> <td>Details:</td> <td><textarea name="details" cols="50" rows="10" ><? echo $details; ?></textarea></td> </tr> <tr> <td>Price for S-XL:<br /> <br /><strong><div id="redfont">**Shirts**<br />&<br />**Hats**</div></strong></td> <td>1-23: <input type="text" name="price" value="<? echo $price; ?>"><br><br> 24-47: <input type="text" name="price2" value="<? echo $price2; ?>"><br><br> 48+: <input type="text" name="price3" value="<? echo $price3; ?>"><br><br> </td> </tr> <tr> <td>Price for 2XL - 5XL:<br /> <br /><strong><div id="redfont">**Shirts ONLY!**</div></strong></td> <td>1-23: <input type="text" name="price4" value="<? echo $price4; ?>"><br><br> 24-47: <input type="text" name="price5" value="<? echo $price5; ?>"><br><br> 48+: <input type="text" name="price6" value="<? echo $price6; ?>"><br><br> </td> </tr> <tr> <td>Minimum QTY: </td> <td><input type="text" name="minimum" value="<? echo $minimum; ?>"></td> </tr> <tr> <td>Sizes:</td> <td><? echo ''; $result = mysql_query("SELECT * FROM sizes"); while ($row = mysql_fetch_assoc($result)) { $selected = ''; $result2 = mysql_query("SELECT * FROM productoptions WHERE productid = '" . $_GET['id'] . "' AND sizeid = '" . $row['id'] . "'"); if ($row2 = mysql_fetch_assoc($result2)) { $selected = 'checked '; } echo '<input type="checkbox" name="size[]" value="' . $row['id'] . '" ' . $selected . '/> ' . $row['size'] . '<br />'; } ?> </td> </tr> <tr> <td>Colors:</td> <td><? $result = mysql_query("SELECT * FROM colors"); while ($row = mysql_fetch_assoc($result)) { $selected = ''; $result2 = mysql_query("SELECT * FROM productoptions WHERE productid = '" . $_GET['id'] . "' AND colorid = '" . $row['id'] . "'"); if ($row2 = mysql_fetch_assoc($result2)) { $selected = 'checked '; } echo '<input type="checkbox" name="color[]" value="' . $row['id'] . '" ' . $selected . '/> ' . $row['color'] . '<br />'; } ?> </td> </tr> <tr> <td> </td> <td><input type="Submit" value="Update this product"></td> </tr> </form> </table> <?php } require("footer.php"); ?> If I missed any information you need, please let me know. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199084 Share on other sites More sharing options...
TCombs Posted April 9, 2011 Author Share Posted April 9, 2011 Also, The script I have is passing the last box checked for each (color and size) to the database, but it's not passing all of the sizes/colors that are selected. For example: Sizes 1. Small = checked 2. medium = checked 3. large = checked Colors 1. white = checked 2. black = checked 3. grey = checked Rather than passing all 3 sizes and all 3 colors, it is only sending Large & Grey to the database. when it should be sending (small, medium, large) and (white, black, grey). It's sending it as a single value, rather than an array. Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199086 Share on other sites More sharing options...
kenrbnsn Posted April 9, 2011 Share Posted April 9, 2011 Please post the form. Ken Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199087 Share on other sites More sharing options...
TCombs Posted April 9, 2011 Author Share Posted April 9, 2011 This is the new product form.. <?php session_start(); require("config.php"); require("db.php"); require("functions.php"); if(isset($_SESSION['SESS_ADMINLOGGEDIN']) == FALSE) { header("Location: " . $config_basedir); } if(isset($_GET['func']) == TRUE) { if($_GET['func'] != "conf") { header("Location: " . $config_basedir); } $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); header("Location: " . $config_basedir . "adminproducts.php"); } else { require("header.php"); ?> <form action="insert.php" method="post"> <table width="500" border="1" cellpadding="10"> <tr> <td>Active:</td> <td><input name="active" type="radio" value="0" />Yes<br /> <input name="active" type="radio" value="1" />No</td> </tr> <tr> <td>Category:</td> <td><input name="cat_id" type="radio" value="1" />Hats<br /> <input name="cat_id" type="radio" value="2" />Shirts<br /> <input name="cat_id" type="radio" value="3" />Promotional Items</td> </tr> <tr> <td>Product ID: </td> <td><input type="text" name="name"></td> </tr> <tr> <td>Short Description: </td> <td><input type="text" name="description"></td> </tr> <tr> <td>Details:</td> <td><textarea name="details" cols="50" rows="10"></textarea></td> </tr> <tr> <td>Price for S-XL:<br /> <br /><strong><div id="redfont">**Shirts**<br />&<br />**Hats**</div></strong></td> <td>1-23: <input type="text" name="price"><br><br> 24-47: <input type="text" name="price2"><br><br> 48+: <input type="text" name="price3"><br><br> </td> </tr> <tr> <td>Price for 2XL - 5XL:<br /> <br /><strong><div id="redfont">**Shirts ONLY!**</div></strong></td> <td>1-23: <input type="text" name="price4"><br><br> 24-47: <input type="text" name="price5"><br><br> 48+: <input type="text" name="price6"><br><br> </td> </tr> <tr> <td>Minimum QTY: </td> <td><input type="text" name="minimum"></td> </tr> <!-- <tr> <td>Price for<br /> One Size Fits Most<br /> <strong><div id="redfont">(For HATS)</div></strong></td> <td>1-23: <input type="text" name="price7"><br><br> 24-47: <input type="text" name="price8"><br><br> 48+: <input type="text" name="price9"><br><br> </td> </tr>--> <!--<tr> <td>Color Options:</td> <td><input type="text" name="color1"> <input type="text" name="color2"> <input type="text" name="color3"> <input type="text" name="color4"><br><br> <input type="text" name="color5"> <input type="text" name="color6"> <input type="text" name="color7"> <input type="text" name="color8"><br><br> <input type="text" name="color9"> <input type="text" name="color10"> <input type="text" name="color11"> <input type="text" name="color12"><br><br> <input type="text" name="color13"> <input type="text" name="color14"> <input type="text" name="color15"> <input type="text" name="color16"><br><br> </td> </tr>--> <tr> <td>Sizes:</td> <td> <? $result = mysql_query("SELECT * FROM sizes"); while ($row = mysql_fetch_assoc($result)) { echo '<input type="checkbox" name="size[]" value="' . $row['id'] . '" /> ' . $row['size'] . '<br />'; } ?> </td> </tr> <tr> <td>Colors:</td> <td> <? $result = mysql_query("SELECT * FROM colors"); while ($row = mysql_fetch_assoc($result)) { echo '<input type="checkbox" name="color[]" value="' . $row['id'] . '" /> ' . $row['color'] . '<br />'; } ?> </td> </tr> <tr> <td> </td> <td><input type="Submit" value="Finish this Item"></td> </tr> </form> </table> <?php } require("footer.php"); ?> Then, the insert.php file inserts the new product info into the database: insert.php <?php header("Location: " . $config_basedir . "adminhome.php"); include("config.php"); include("db.php"); $active=$_POST['active']; $cat_id=$_POST['cat_id']; $name=$_POST['name']; $description=$_POST['description']; $details=$_POST['details']; $price=$_POST['price']; $price2=$_POST['price2']; $price3=$_POST['price3']; $price4=$_POST['price4']; $price5=$_POST['price5']; $price6=$_POST['price6']; $minimum=$_POST['minimum']; $price7=$_POST['price7']; $price8=$_POST['price8']; $price9=$_POST['price9']; $arrsizes = $_POST['size']; $arrcolors = $_POST['color']; $image=$_POST['image']; mysql_query("INSERT INTO products (active, cat_id, name, description, details, price, price2, price3, price4, price5, price6, minimum, image) VALUES ('$active','$cat_id','$name','$description','$details','$price','$price2','$price3','$price4','$price5','$price6','$minimum','$image')"); $result = mysql_query("SELECT id FROM products ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $productid = $row['id']; } foreach ($arrsizes as $sizevalue) { foreach ($arrcolors as $colorvalue) { mysql_query("INSERT INTO productoptions (productid, sizeid, colorid) VALUES ('" . $productid . "', '" . $sizevalue . "', '" . $colorvalue . "')"); } } ?> The above code generates the original product and working perfectly. :-) Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199088 Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 I'm pretty sure I understand it now, but I missed some quotes in my last post. So here it is again, try it and see if it works. <?php include("config.php"); include("db.php"); $id=$_POST['id']; $active=$_POST['active']; $cat_id=$_POST['cat_id']; $name=$_POST['name']; $description=$_POST['description']; $details=$_POST['details']; $price=$_POST['price']; $price2=$_POST['price2']; $price3=$_POST['price3']; $price4=$_POST['price4']; $price5=$_POST['price5']; $price6=$_POST['price6']; $minimum=$_POST['minimum']; $arrsizes = $_POST['size']; $arrcolors = $_POST['color']; $image=$_POST['image']; $sql="UPDATE products SET active = '$active', cat_id = '$cat_id', name = '$name', description = '$description', details = '$details', price = '$price', price2 = '$price2', price3 = '$price3', price4 = '$price4', price5 = '$price5', price6 = '$price6', minimum = '$minimum', image = '$image' WHERE id = '$id'"; mysql_query($sql) or die ("Error: ".mysql_error()); echo $sql."<br>\n"; $result = mysql_query("SELECT id FROM products ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $productid = $row['id']; //not sure what this is for??? } mysql_query("DELETE FROM productoptions WHERE productid='$id'"); foreach ($arrsizes as $sizevalue) { foreach ($arrcolors as $colorvalue) { $sql2 = "INSERT INTO productoptions (productid, sizeid, colorid) VALUES ('$id', '$sizevalue', '$colorvalue')"; mysql_query($sql2) or die("Error: ".mysql_error()); echo $sql2."<br>\n"; } } header("Location: " . $config_basedir . "adminhome.php"); ?> Edit: just saw your new code. Doesn't that create rows that might already be there though? Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199090 Share on other sites More sharing options...
TCombs Posted April 9, 2011 Author Share Posted April 9, 2011 @dcro2 .......THANK YOU!!!! Works perfectly!!! I've spent 2 days and about 20hrs trying to figure this out! Thanks again!!!!! :-) I'm pretty sure I understand it now, but I missed some quotes in my last post. So here it is again, try it and see if it works. <?php include("config.php"); include("db.php"); $id=$_POST['id']; $active=$_POST['active']; $cat_id=$_POST['cat_id']; $name=$_POST['name']; $description=$_POST['description']; $details=$_POST['details']; $price=$_POST['price']; $price2=$_POST['price2']; $price3=$_POST['price3']; $price4=$_POST['price4']; $price5=$_POST['price5']; $price6=$_POST['price6']; $minimum=$_POST['minimum']; $arrsizes = $_POST['size']; $arrcolors = $_POST['color']; $image=$_POST['image']; $sql="UPDATE products SET active = '$active', cat_id = '$cat_id', name = '$name', description = '$description', details = '$details', price = '$price', price2 = '$price2', price3 = '$price3', price4 = '$price4', price5 = '$price5', price6 = '$price6', minimum = '$minimum', image = '$image' WHERE id = '$id'"; mysql_query($sql) or die ("Error: ".mysql_error()); echo $sql."<br>\n"; $result = mysql_query("SELECT id FROM products ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $productid = $row['id']; //not sure what this is for??? } mysql_query("DELETE FROM productoptions WHERE productid='$id'"); foreach ($arrsizes as $sizevalue) { foreach ($arrcolors as $colorvalue) { $sql2 = "INSERT INTO productoptions (productid, sizeid, colorid) VALUES ('$id', '$sizevalue', '$colorvalue')"; mysql_query($sql2) or die("Error: ".mysql_error()); echo $sql2."<br>\n"; } } header("Location: " . $config_basedir . "adminhome.php"); ?> Edit: just saw your new code. Doesn't that create rows that might already be there though? Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199092 Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 Oh... really? Great! You're welcome. Glad I could help. Now I just need a good night's sleep. *drops dead* Quote Link to comment https://forums.phpfreaks.com/topic/233156-update-array-isnt-sending-entire-array-to-row/#findComment-1199095 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.