phoenixx Posted April 28, 2010 Share Posted April 28, 2010 I have a user search form to limit quantities on the returned search using variable $viewquantity. I need to return $viewquantity rows using a LIMIT in the sql select statement but running into a roadblock when I use: $result_adhistory = mysql_query("SELECT * FROM adtracker WHERE adtracker_adid NOT LIKE '%index%' AND adtracker_clientid LIKE '%handr%' AND adtracker_adid > '' AND adtracker_pagetitle > '' AND adtracker_status > '' AND adtracker_adstamp > '' ORDER BY adtracker_adstamp DESC LIMIT '$viewquantity' ") or die ('Error: '.mysql_error ()); I tried using SET SQL_SELECT_LIMIT = ($viewquantity); on the line before the SQL statement but get an error: Parse error: syntax error, unexpected T_STRING in /home/xxx/public_html/xxx/xxx/xxx/ad_history_reporter.php on line 135 Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/200055-php-mysql-select-with-dynamic-limit-variable/ Share on other sites More sharing options...
Baez Posted April 28, 2010 Share Posted April 28, 2010 Try this: $result_adhistory = mysql_query("SELECT * FROM adtracker WHERE adtracker_adid NOT LIKE '%index%' AND adtracker_clientid LIKE '%handr%' AND adtracker_adid > '' AND adtracker_pagetitle > '' AND adtracker_status > '' AND adtracker_adstamp > '' ORDER BY adtracker_adstamp DESC LIMIT ".$viewquantity) Link to comment https://forums.phpfreaks.com/topic/200055-php-mysql-select-with-dynamic-limit-variable/#findComment-1049993 Share on other sites More sharing options...
phoenixx Posted April 28, 2010 Author Share Posted April 28, 2010 PERFECT!!!! Many Thanks!!! Link to comment https://forums.phpfreaks.com/topic/200055-php-mysql-select-with-dynamic-limit-variable/#findComment-1050003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.