alexcrosson Posted September 30, 2006 Share Posted September 30, 2006 I'm trying to create a simpl blog for a website. And I can get it to output the entires but now I wanted the entries to be sorted by date they were submited.Heres basicly all my code:[code]<?php $host = "localhost"; $user = "***"; $pass = "****"; $database = "*****"; $conn = mysql_connect($host,$user,$pass) or die ("Unable to connect to Database"); mysql_select_db($database); $result = mysql_query("SELECT * FROM blog") or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo "<div id='blog'><h1>". $row['title']. "</h1><p>". $row['content']. "</p>". "<br /><h6>Post On: ". $row['date']. "</h6></div>"; }?>[/code]Can anyone help me? I would greatly appreciate it. Quote Link to comment Share on other sites More sharing options...
extrovertive Posted September 30, 2006 Share Posted September 30, 2006 I don't know what column you're using for your date stamp, but just change "date" below to what you have for your date column.$result = mysql_query("SELECT * FROM blog ORDER BY date") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
alexcrosson Posted September 30, 2006 Author Share Posted September 30, 2006 I used date as my column name and it doesn't work??? This sucks i'm lost. Quote Link to comment Share on other sites More sharing options...
extrovertive Posted September 30, 2006 Share Posted September 30, 2006 $result = mysql_query("SELECT * FROM blog ORDER BY date ASC") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
alexcrosson Posted September 30, 2006 Author Share Posted September 30, 2006 Wait do you mean column or row? Or are they the same thing? Sorry I'm kinda noob to PHP and MySQL. Quote Link to comment Share on other sites More sharing options...
extrovertive Posted September 30, 2006 Share Posted September 30, 2006 column/field in your table Quote Link to comment Share on other sites More sharing options...
alexcrosson Posted September 30, 2006 Author Share Posted September 30, 2006 Alright I got it to work properly. All i had to do was change the ASC to DESC to get the effect I wanted. Thanks for your help. Quote Link to comment 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.