Hi,
I was wondering is it possible to perform the below sql query with an array? - it's not working for me.
Could it be that my syntax is wrong?
$SQL2 = "UPDATE $table1 SET ".room[$i]."=' ', ".bRoom[$i]."=' ', ".room[$i]Company."=' ', ".room[$i]Initials."=' ', ".room[$i]dateAdded"=' ' WHERE id='$id'";
It works perfectly when i replace the array [$i] with 1 or 2, etc.
My code is checking what record's were added over a week ago - it is supposed to then update those records by clearing their data.
Here's my code:
=================
$length_days = 7;
for($i=1; $i < 7; $i++)
{
$id = $row[id]."\t";
${"room".$i} = $row["room".$i]."\t";
${"bRoom".$i} = $row["bRoom".$i]."\t";
${"room".$i."Company"} = $row["room".$i."Company"]."\t";
${"room".$i."Initials"} = $row["room".$i."Initials"]."\t";
${"room".$i."dateAdded"} = $row["room".$i."dateAdded"]."\t";
list( $year,$month,$day) = split ('[/.-]', ${"room".$i."dateAdded"});
echo $hold_until_date = date('Y-m-d', mktime(0, 0, 0, $month, $day + $length_days, $year));
if ($hold_until_date < date("Y-m-d"))
{
$SQL2 = "UPDATE $table1 SET ".room[$i]."='', ".bRoom[$i]."='', ".room[$i]Company."='', ".room[$i]Initials."='', ".room[$i]dateAdded"='' WHERE id='$id'";
$result2 = @($SQL2) or die("could not complete your query");
mysql_data_seek($result2,0);
}
Any help would be greatly appreciated!
Thanks in advance