SUNIL16 Posted September 15, 2008 Share Posted September 15, 2008 Hi friends, I created an forum in my website and i done paging also, the problem is i given auto increment while creating table in database below is the code i used mysql_query("CREATE TABLE `forum_question` ( `id` int(4) NOT NULL auto_increment, `topic` varchar(255) NOT NULL default'0', `detail` longtext NOT NULL, `name` varchar(65) NOT NULL default '0', `datetime` varchar(25) NOT NULL default'0', `view` int(4) NOT NULL default '0', `reply` int(4) NOT NULL default '0', PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=1 "); Now the problem is the first 10 result i am getting is not the latest messages.These are very first messages. so i want to display the latest message in the first retrieval page. how can i do that? Link to comment https://forums.phpfreaks.com/topic/124322-hi-friends-some-help-needed/ Share on other sites More sharing options...
Mchl Posted September 15, 2008 Share Posted September 15, 2008 `datetime` varchar(25) NOT NULL default'0', Don't store datetime as VARCHAR Use DATETIME Then you can sort by that column and get proper results. SELECT * FROM forum_question ORDER BY `datetime` DESC Link to comment https://forums.phpfreaks.com/topic/124322-hi-friends-some-help-needed/#findComment-642003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.