Reputation: 107
I want to increment a value in MySQL everyday. Starting with 0 and adding +1 for each day.
I've looked at several methods but it usually involves parsing it out of the calendar and starts getting messy. Does anyone have a nice solution for how I could do this in php/mysql?
Reason: I have a table of data and want to email 1 row each day. So row 0 will send on day one, then row 2 on day 2.
Upvotes: 1
Views: 1150
Reputation: 11
You can use difference between days to get id , so every day you got a new id
class Helper
{
public static $start=1523664000; //2018-04-13
public static function getRowOfToday(){
$now = time(); // or your date as well
$datediff = $now - Helper::$start;
$id = round($datediff / (60 * 60 * 24));
return $id;
}
}
then you can call Helper::getRowOfToday()
to get the current row
Upvotes: 1