12-07-2007, 07:49 AM
|
#2 (permalink)
|
|
The Contributor
Join Date: Dec 2007
Posts: 60
Thanks: 5
|
You cannot have PHP code inside of a MySQL query, as far as I know. You will have to patch the query together (you can use whatever methods you like [EG: printf])
PHP Code:
/** * Hard-coded method */ $dbname = 'categories'; $cat = 1; // Remember this _HAS_ to be an integer $from = 0; $max_results = 15;
/** * Accept input from url */ $dbname = 'categories'; // this shouldn't be in the url $cat = isset( $_REQUEST['cat'] ) ? (int)$_REQUEST['cat'] : 1; $from = isset( $_REQUEST['from'] ) ? (int)$_REQUEST['from'] : 0; $max_results = isset( $_REQUEST['max_results'] ) ? (int)$_REQUEST['max_results'] : 15;
$result = mysql_query('SELECT * FROM '. $dbname .' WHERE cat = '. $cat .' ORDER BY updated DESC LIMIT '. $from .','. $max_results);
I hope that helps, this is primitive 
|
|
|
|