Quote:
Originally Posted by Uberbots
[php]
and sam, it would be more efficient to use a LIMIT statement in your SQL query to limit the rows listed (and you can do pages with that too).
|
I was going to add the LIMIT in the query, but I figured since he was just learning about MySQL and PHP, just give him little chunks at a time. Thanks for pointing that out though.
With the database limit it would be,
PHP Code:
[...CODE CUT...]
$image_limit = 20; //change to any number.
[...CODE CUT...]
mysql_select_db($DB); //select database
$query = '"SELECT * FROM `PICTURES` LIMIT 0,' .$image_limit. '"'; //select items from column PICTURES
$results = mysql_query($query);
Here is a quick definition of the LIMIT command. LIMIT is used to
limit the number of results returned by MySQL. It requires 2 values, X and Y. X being the first result you want (The starting position) Y being the number of results you want. I said LIMIT 0, [20] because 0 is always the lowest result in the database, so the output would be the first 20 results in your database.