homepage Welcome to WebmasterWorld Guest from 54.226.147.84
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Query Help
BlackRaven

10+ Year Member



 
Msg#: 3337506 posted 10:20 pm on May 11, 2007 (gmt 0)

I am trying to provide users with the sites recent popular list like the digg right column top 10 in all topics. However i am not sure if it is possible to achieve this with one query.

$query_top=mysql_query("SELECT * FROM frontpage ORDER BY post_date, total_votes DESC LIMIT 15, 45") or die(mysql_error());

The query looks at entries that are not on the frontpage and finds the 30 posts after that, however it does not arrange them according to the total votes

 

mcibor

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3337506 posted 8:35 am on May 12, 2007 (gmt 0)

yes, it doesn't because you sort first by time, and only then by votes.

The correct one would seem to be:

$sql = "SELECT * FROM frontpage WHERE id NOT IN (SELECT id FROM frontpage ORDER BY post_date LIMIT 30) ORDER BY total_votes DESC LIMIT 15";

I think this should do the trick.
Michal

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved