On 3/30/02 4:50 PM Paul DuBois wrote: > At 9:50 -0600 3/30/02, Alex Behrens wrote: >> Hey guys, >> >> quick question, I'm setting up a script that does headlines for my site and >> I need to pull some information from a table with my review info from it but >> I only want to view the 7 latest reviews, how do I make it so I can only >> view like 7 highest values for the "num" column? >> >> my query is this: >> $r = mysql_query("SELECT * FROM hwureviews LIMIT (MAX(num)-7),7"); Does this >> work or am I way off? > > It won't work. The arguments to LIMIT must be constants. > >>
Statements like this work in PHP: $limitBegin= (MAX(num)-7); /* I did not test MAX(num), you may have to make a seperate query to get this value */ $limitEnd = 7; $selectAllSQL =" SELECT * FROM $theTable LIMIT ($limitBegin, $ limitEnd) "; /* selectAllSQL is a string. to test echo "selectAllSQL = $selectAllSQL'; */ $r = mysql_query($selectAllSQL); Hope this helps: Chris -- Chris Adams Cypress Lake Studios Hypermedia, Quicktime, and Internet Design http://www.cypresslakestudios.com [EMAIL PROTECTED] --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php