Jump to content

array help please


bradynorman

Recommended Posts

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 way
thanks
Mike
Link to comment
https://forums.phpfreaks.com/topic/26877-array-help-please/
Share on other sites

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

thank you - that did the trick
the 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.
cheers
Mike
Link to comment
https://forums.phpfreaks.com/topic/26877-array-help-please/#findComment-122903
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.