The hosting service provider has set up a "cron" job to automatically execute a script on my web hosting.
What I am wanting the script to do is rotate the "days" column in the table. For example if the "id" column value is "20" and the "day" column value is "7" I want the script to change the day to "1", if the "id" column value is "22" and the "day" column value is "3" I want the script to change the day to "4" - and so forth.
Basically, what I want to do is each time the cron job executes I want to advance the value in the "day" column by one day. If the day column value is set at the value 7 then I want to start it all over again and set the value to the first day (1).
The example data set before and after changes are made is below:
// Example table data
// Data set before changes are made
id day
20 7
22 3
24 5
26 6
27 1
// Data set after changes are made.
id day
20 1 // Advanced one day from the previous day.
22 4 // Advanced one day from ....
24 6 // etc. etc.
26 7
27 2
// Extracts current values for the "day" column here.
$Query = "SELECT id, day FROM table";
$Result = mysql_db_query ($db_info[dbname], $Query, $db_connection);
while ($Row = mysql_fetch_array ($Result)){
$id[] = "".$Row["id"]."\n";
$day[] = "".$Row["day"]."\n"; // Need to advance this by one day.
$CountRows++;
}
// Need to somehow advance the "day" column value by one day here.
for ($n=1; $n<=$CountRows; $n++){
// Then insert the advanced value back into the column.
"UPDATE $TableName SET day = '$day' WHERE id='$id'";
}
The table holds information about realtor house listings. The reason that I need this script is so that when the listings are displayed on the page the listings are changed or rotated each day with new listings at the top of the page each day.
Thanks