View Single Post
  #9   Spotlight this post!  
Unread 27-06-2007, 13:39
SamC SamC is offline
.
AKA: Sam Couch
FRC #0103 (Cybersonics)
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Philadelphia, PA
Posts: 583
SamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond repute
Re: Dynamic Tables in PHP

Quote:
Originally Posted by Uberbots View Post
[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.