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
ORDER by latest? (MYSQL)
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: ORDER by latest? (MYSQL)
I tried that and it gave my a query error.arborint wrote:ORDER BY `add_date` DESC
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: ORDER by latest? (MYSQL)
What is the name of the column you want to sort by?
Re: ORDER by latest? (MYSQL)
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.
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)
*bump*
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: ORDER by latest? (MYSQL)
Please be aware of rules. Thank you.[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.
In relation to your problem:
Code: Select all
<?php
$query = "SELECT * FROM mytable ORDER BY `Wall_ID` DESC LIMIT 0, 4";
?>