I have a table with holiday destinations in with a visit_date column and a status column.
visit date is when they plan to go/or have been to this destination. When these holidays are being inserted into database, I wrote this to determine if the people are going or have been on this trip.
$date = $_POST['date'];
$today = date("Y/m/d");
if($date<$today){
$status="been";
}else{
$status="going";
}
But what I need to do is write a script that runs after the insert to update the status of the old holiday plans from going to been if the visit_date is less than todays date as in yesterday, last week etc..
this is what I have so far
$result = mysql_query("SELECT * FROM trips");
while($row = mysql_fetch_array($result))
{
//echo $row['visit_date'];
if ($row['visit_date'] < $today){
echo "this trip has already happened";
//code to update status if trip already happened
}
}
You can do:
But you know what would even be better? Get rid of of the
statuscolumn. Then whenever you need to select trips and want to figure out their status, use a conditionalIFstatement like so: