I have been working on a game, and now at the point that i"m creating packages that users can purchase. They are limited to certain times of the month, or limited to when I activate the package. When I activate the package, it inserts the datetime and 3 days after, the finish time.
Code: Select all
if($_POST['activatepack']){
$date = date('Y-m-d H:i:s');
$sql = "UPDATE dk_packages SET active='Yes', startdate='$date', enddate='$date'+INTERVAL 3 DAY WHERE package_id=1";
$query = mysqli_query($db_conx, $sql);
$sql = "UPDATE dk_packages SET active='Yes', startdate='$date', enddate='$date'+INTERVAL 3 DAY WHERE package_id=2";
$query = mysqli_query($db_conx, $sql);
$sql = "UPDATE dk_packages SET active='Yes', startdate='$date', enddate='$date'+INTERVAL 3 DAY WHERE package_id=3";
$query = mysqli_query($db_conx, $sql);
What I need though, is for it to update a row in the database after every 1 day until the activity is over with.
So let's say it starts at 12:00 on the 3rd and goes til 12:00 on the 6th.....
I need it to update the table row on the 4th at 12:00 and on the 5th at 12:00....
I have tried something like this, but not working:
Code: Select all
$sql = "UPDATE dk_pack_purch SET pack_1='No' WHERE charname='$charname' && pk1_starttime >= '$pk1_starttime' + INTERVAL 1 DAY)";
$querytime = mysqli_query($db_conx, $sql);
Code: Select all
$sql = "SELECT * FROM dk_packages WHERE package_id=1";
$user_query2 = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query2);
$row = mysqli_fetch_array($user_query2, MYSQLI_ASSOC);
$pk1_starttime = $row['startdate'];