brooksh Posted April 17, 2013 Share Posted April 17, 2013 When I submit my form, it limits the update to 1 character. For example if I put "Description" as the description, it inserts "d" in the database. What is wrong with my code? $size = count($_POST['checkbox']); // start a loop in order to update each record $i = 0; while ($i < $size) { // define each variable $title2= $_POST['title'][$i]; $description2= $description[$i]; $edit= $_POST['checkbox'][$i]; mysql_query("UPDATE `categories` SET `title`='$title2',`description`='$description2' WHERE id ='$edit'"); ++$i; } Quote Link to comment https://forums.phpfreaks.com/topic/277040-multiple-array-not-updating-correctly/ Share on other sites More sharing options...
Solution Barand Posted April 17, 2013 Solution Share Posted April 17, 2013 It looks as though $description is a string and not an array so it takes the i'th character of the string rather than the i'th element of an array. Quote Link to comment https://forums.phpfreaks.com/topic/277040-multiple-array-not-updating-correctly/#findComment-1425299 Share on other sites More sharing options...
brooksh Posted April 17, 2013 Author Share Posted April 17, 2013 I had <input type="text" value="<?=$row[description]?>" name="description"> instead of <input type="text" value="<?=$row[description]?>" name="description[]"> Quote Link to comment https://forums.phpfreaks.com/topic/277040-multiple-array-not-updating-correctly/#findComment-1425409 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.