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; } Link to comment https://forums.phpfreaks.com/topic/277040-multiple-array-not-updating-correctly/ Share on other sites More sharing options...
Barand Posted April 17, 2013 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. 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[]"> 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
Archived
This topic is now archived and is closed to further replies.