I'm about to create a page with recent activities and I couldn't make it work. I'm just starting to code php so please pardon me
I'm trying to test it with this code but the results are not sorted by the time
$sql = "SELECT * FROM `editlog`, `deletelog`, `loginlog`, `logoutlog` ORDER BY COALESCE(editlog.time , deletelog.time, loginlog.time, logoutlog.time) ASC";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo $row[0].'<br />';
echo $row[1].'<br />';
echo $row[2].'<br />';
echo $row[3].'<br />';
}
What i'm trying to do is select all data from tables editlog, deletelog, loginlog, and logoutlog then merge the results. Then sort them based from the datetime in ascending order.
then after collecting the information(already sorted) it will be displayed like this
e.g
datetime ------------------ emp id ----------- activity
2016-07-10 10:54:01 --- 100 --------------- logged in
2016-07-10 10:55:05 ----102 --------------- deleted record no 23
2016-07-10 10:57:00---- 103 --------------- logged in
2016-07-10 10:58:00---- 103 --------------- logged out
2016-07-10 10:58:30---- 103 --------------- edit record no 24
Question
Technoken
I'm about to create a page with recent activities and I couldn't make it work. I'm just starting to code php so please pardon me
I'm trying to test it with this code but the results are not sorted by the time
What i'm trying to do is select all data from tables editlog, deletelog, loginlog, and logoutlog then merge the results. Then sort them based from the datetime in ascending order.
then after collecting the information(already sorted) it will be displayed like this
e.g
datetime ------------------ emp id ----------- activity
2016-07-10 10:54:01 --- 100 --------------- logged in
2016-07-10 10:55:05 ----102 --------------- deleted record no 23
2016-07-10 10:57:00---- 103 --------------- logged in
2016-07-10 10:58:00---- 103 --------------- logged out
2016-07-10 10:58:30---- 103 --------------- edit record no 24
Here's a sample of the database
For anybody who can help. Thank you so much!
Edited by TechnokenLink to comment
Share on other sites
4 answers to this question
Recommended Posts