Page 1 of 1
ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 5:41 pm
by xenoalien
I have a database of wallpaper at
http://www.wallpapersearch.net and would like to make the "latest" part of the website be based on a mysql query that orders by latest? Is this possible? At the top I have it order by rand or random.
Thanks
Re: ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 5:50 pm
by Christopher
ORDER BY `add_date` DESC
Re: ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 5:59 pm
by xenoalien
arborint wrote:ORDER BY `add_date` DESC
I tried that and it gave my a query error.
This is what I did:
$query = "SELECT * FROM mytable ORDER BY `add_date` DESC LIMIT 0, 4";
This is how I have it now:
$query = "SELECT * FROM mytable ORDER BY RAND() LIMIT 0, 4";
I don't have a date column but I do have an "ID" (auto increment) column if that helps.
Re: ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 6:18 pm
by RobertGonzalez
What is the name of the column you want to sort by?
Re: ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 6:59 pm
by xenoalien
Wall_ID
edit: Basically the highest id down. So if my highest number was 1234 I would want it to order from there to 1230 using limit.
Re: ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 9:16 pm
by xenoalien
*bump*
Re: ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 10:50 pm
by Christopher
arborint wrote:ORDER BY `Wall_ID` DESC LIMIT 4
Re: ORDER by latest? (MYSQL)
Posted: Sun Apr 27, 2008 10:50 pm
by RobertGonzalez
Please be aware of rules. Thank you.
In relation to your problem:
Code: Select all
<?php
$query = "SELECT * FROM mytable ORDER BY `Wall_ID` DESC LIMIT 0, 4";
?>
Try that and see what it does.