bradynorman Posted November 10, 2006 Share Posted November 10, 2006 using form checkboxes i am able to send an array.below is the code that i would like to use to process this date.$total = count($ron);for($i = 0; $i < $total; $i++) { echo "$ron[$i], ";}$query = "UPDATE ecs SET stat = 'returned', retdate='$dateret' WHERE ron = XXXXXXX ";the for loop presents the data in the following format;test1, test2, test3, continuing for as many entriesthat there are in the loop.What I need to be able to do is to enter this data into the $query statement.any ideas please or am I going about this the wrong waythanksMike Link to comment https://forums.phpfreaks.com/topic/26877-array-help-please/ Share on other sites More sharing options...
trq Posted November 10, 2006 Share Posted November 10, 2006 Your question is a little vague, sorry. But a foreach is a little simpler than a for. eg; [code=php:0]foreach($ron as $val) { $query = "UPDATE ecs SET stat = 'returned', retdate = '$dateret' WHERE ron = '$val'"; mysql_query($query) or die(mysql_error());}[/code]Not sure where your defining $dateret? Link to comment https://forums.phpfreaks.com/topic/26877-array-help-please/#findComment-122898 Share on other sites More sharing options...
bradynorman Posted November 10, 2006 Author Share Posted November 10, 2006 thank you - that did the trickthe complete code is now:mysql_select_db($database_ecs, $ecs);$dateret = date("Y-m-j");$total = count($ron);foreach($ron as $val) { $query = "UPDATE ecs SET stat = 'returned', retdate = '$dateret' WHERE ron = '$val'"; mysql_query($query) or die(mysql_error());}mysql_query($query);mysql_close();$updateGoTo = "ron_comp.php";header(sprintf("Location: %s", $updateGoTo));As I said THANK YOU.cheersMike Link to comment https://forums.phpfreaks.com/topic/26877-array-help-please/#findComment-122903 Share on other sites More sharing options...
trq Posted November 10, 2006 Share Posted November 10, 2006 You dont need that mysql_query() call after the loop. It all takes place within the loop. Link to comment https://forums.phpfreaks.com/topic/26877-array-help-please/#findComment-122905 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.