Log in

View Full Version : Order by date



captainjustin
01-10-2011, 03:16 AM
I have been playing with this photo album script for a while and it works just fine but I'm having problems ordering the pictures by the date. I have one page that displays all the thumbnails and since the new year it's all out of order.. I've tried a couple of things but, I'm still pretty green and I can't figure it out. I would like for it to display all the pics starting with the most recent pictures to the oldest.

Thanks in advance for your help!



<?

//////// My query that is probably all screwed up


$sql = mysql_query("SELECT * FROM photo_album ORDER BY pmonth desc, pday desc, pyear desc");

echo '<table align=center>';
// Check to see if any results were returned
if(mysql_num_rows($sql) > 0){
echo '<tr>';
// Loop through the results
while($row = mysql_fetch_array($sql)){
echo 'Bla Bla Bla Bla';



?>

jscheuer1
01-10-2011, 04:43 AM
Try:


$sql = mysql_query("SELECT * FROM photo_album ORDER BY pyear desc, pmonth desc, pday desc");

captainjustin
01-10-2011, 05:34 AM
Ok I figured it out.... My picture dates were listed like so 1/15/2010 so I changed the date to read like so 01/15/2010 ....... That and order by pyear desc first ..... Thanks for your help John