I am trying to create an event which should repeat every week at the same time.
This is what I have right now:
User sends postString to my php script looking like this:
weekly=true&dateFrom=2016-10-01 14:00&dateTo=2016-10-01 15:00&usrId=1
Then my MySQL statement with php script insert these data to MySQL DB. This is my inserting function:
public function newEvent($weekly, $dateFrom, $dateTo, $usrId) {
$sql = "insert into myTableName set weekly=?, dateFrom=?, dateTo=?, usrId=?";
$statement = $this->conn->prepare($sql);
if (!$statement)
throw new Exception($statement->error);
$statement->bind_param("ssss", $weekly, $price, $sport, $participants, $latitude, $longitude, $description, $dateFrom, $dateTo, $usrId, $title);
$returnValue = $statement->execute();
return $returnValue;
}
It works fine , but my actual goal is:
When user sends postString like example above and if weekly is true
I would like my event to repeat every week at the same time and I would like to be able to search the event in some future week.
Example: My weekly=true&dateFrom=2016-10-01 14:00&dateTo=2016-10-01 15:00&usrId=1 is like this and if I ran this MySQL statement
SELECT *
FROM myTableName WHERE dateFrom >= 2016-10-08 13:00
AND dateTo <= 2016-10-08 16:00 LIMIT 0 , 30
I would like to get the data from my event which had time dateFrom=2016-10-01 14:00&dateTo=2016-10-01 15:00 when it was created.
My question is:
Is there any way how can I accomplish the thing I have just described?
If you need more details just let me know. Thank you very much :)