Schlo_50 Posted May 1, 2007 Share Posted May 1, 2007 I want to display the dates (dat) from the database in order 1st, 5th, 15th etc.. How? <? $result = mysql_query ($jan) or die ( mysql_error ()); while ($row = mysql_fetch_array ($result)) { echo ( $row[dat]. ' , ' ); echo ( $row[message]. '<br>' ); } ?></p> Thanks Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/ Share on other sites More sharing options...
clown[NOR] Posted May 1, 2007 Share Posted May 1, 2007 try using ORDER BY maybe.. if i understood your question right Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242643 Share on other sites More sharing options...
Schlo_50 Posted May 1, 2007 Author Share Posted May 1, 2007 Could you revise for me please..Not sure i understand you. Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242646 Share on other sites More sharing options...
Barand Posted May 1, 2007 Share Posted May 1, 2007 Assuming the date is in a DATE field so is formatted as 2007-05-01 echo "date ('jS M, Y', strtotime ($row['dat'])); //--> 1st May, 2007 http://www.php.net/date Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242649 Share on other sites More sharing options...
Schlo_50 Posted May 1, 2007 Author Share Posted May 1, 2007 Its stored as a single number. Field type is INT. Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242650 Share on other sites More sharing options...
clown[NOR] Posted May 1, 2007 Share Posted May 1, 2007 $query = "SELECT * FROM `database` ORDER BY `dat`"; $result = mysql($query); if (!$result) { die(mysql_error()); } while ($row = mysql_fetch_assoc($result)) { echo $row['dat'].' , '.$row['message'].'<br>'; EDIT: You should change the dbfield to DATETIME if you're handeling only dates Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242655 Share on other sites More sharing options...
Barand Posted May 1, 2007 Share Posted May 1, 2007 Its stored as a single number. Field type is INT. So if it's like 1177974000 then you can leave out the strtotime function echo "date ('jS M, Y', $row['dat']); //--> 1st May, 2007 Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242661 Share on other sites More sharing options...
Schlo_50 Posted May 1, 2007 Author Share Posted May 1, 2007 link=topic=138678.msg588067#msg588067 date=1178044486] $query = "SELECT * FROM `database` ORDER BY `dat`"; $result = mysql($query); if (!$result) { die(mysql_error()); } while ($row = mysql_fetch_assoc($result)) { echo $row['dat'].' , '.$row['message'].'<br>'; EDIT: You should change the dbfield to DATETIME if you're handeling only dates Cheers clown Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242666 Share on other sites More sharing options...
clown[NOR] Posted May 1, 2007 Share Posted May 1, 2007 Link to comment https://forums.phpfreaks.com/topic/49505-solved-number-order/#findComment-242670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.