phorcon3 Posted February 8, 2008 Share Posted February 8, 2008 MySQL Table id subject time 1 subject 1 timestamp 2 subject 2 timestamp 3 subject 3 timestamp and what I wanna do is group it by dates, so it would look somewhat like this February 3, 2008 - subject 3 - subject 2 February 2, 2008 - subject 1 for example? anyone know how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/90048-solved-dates/ Share on other sites More sharing options...
beansandsausages Posted February 8, 2008 Share Posted February 8, 2008 possably order by date, the a sub query order by id Quote Link to comment https://forums.phpfreaks.com/topic/90048-solved-dates/#findComment-461686 Share on other sites More sharing options...
phorcon3 Posted February 8, 2008 Author Share Posted February 8, 2008 yeah, thats actually how i have it right now lol ..but i just thought there might be a more efficient way to do it.. but, yah ...cant really come up with anything else either thanks;) Quote Link to comment https://forums.phpfreaks.com/topic/90048-solved-dates/#findComment-461689 Share on other sites More sharing options...
beansandsausages Posted February 8, 2008 Share Posted February 8, 2008 $date = " SELECT * FROM `db` ORDER BY 'date' AND 'id' "; sumit like that maybe ? Quote Link to comment https://forums.phpfreaks.com/topic/90048-solved-dates/#findComment-461691 Share on other sites More sharing options...
laffin Posted February 8, 2008 Share Posted February 8, 2008 that will be in yer php code. before the loop create a prevdate - leave empty, in the loop, compare prevdate with row's timestamp if different, print out the date, save the new prevdate print the info and loop $prevdate='' $while($row=mysql_fetch_assoc($res)) { if($prevdate != $row['ts']) { echo "Date: " . gmdate("Y-m-d",$row['ts']) . "<br>"; $prevdate=$row['ts']; } echo "$row[id]) $row[subject]<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/90048-solved-dates/#findComment-461693 Share on other sites More sharing options...
phorcon3 Posted February 8, 2008 Author Share Posted February 8, 2008 uh, thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/90048-solved-dates/#findComment-461701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.