MySQL Forums
Forum List  »  Newbie

How to Select all Timestamps grouped by Date(Timestapms) PHP/MYSQL
Posted by: Kamel AZIRA
Date: June 21, 2018 05:16AM

Hi guys, So I want to select all timestamps in each days of the last 7 days and put them in a json array, the code that I'm using is :

$sql = "SELECT Time from gps_rt WHERE UID='$uid' group by Date(Time) LIMIT 7";

$result = $link->query($sql);

while ($pdays = mysqli_fetch_array($result)) {

$days['Durees'][$i] = $pdays['Time'];

$i=$i+1;
}

echo json_encode($days);

the problem is that this code shows me only the first Timestamps of each day, and for me I need to get All the Timestapms of each day :

Durees
0: "2018-06-14 12:44:03"
1: "2018-06-15 11:06:07"
2: "2018-06-16 20:40:08"
3: "2018-06-17 18:33:44"
4: "2018-06-18 08:35:44"
5: "2018-06-19 08:09:46"
6: "2018-06-20 10:11:46"

What I want is :

Durees
0: "2018-06-14 12:44:03"
"2018-06-14 12:44:13"
"2018-06-14 12:48:03"
.
.
.
1: "2018-06-15 11:06:07"
"2018-06-15 11:08:17"
.
.
.
2: "2018-06-16 20:40:08"
etc

Options: ReplyQuote


Subject
Written By
Posted
How to Select all Timestamps grouped by Date(Timestapms) PHP/MYSQL
June 21, 2018 05:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.