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
:roll:
arborint wrote:ORDER BY `Wall_ID` DESC LIMIT 4

Re: ORDER by latest? (MYSQL)

Posted: Sun Apr 27, 2008 10:50 pm
by RobertGonzalez
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:4. All users of any level are restricted to bumping (as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not receive a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.
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.