Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm new to PHP. This is prob easy for those who know what theyre doing

Status
Not open for further replies.

NoNamesLeft

Technical User
Dec 14, 2002
2
US
How can I tell this query to only pull out the first 6 records?

And then how do I tell it to pull out records 6 to 12 etc?

Help much appreciated.


<?
include &quot;../../variables.php&quot;;
$query = &quot;SELECT * FROM tblNews&quot;;
$result = mysql_db_query ($dbname, $query);
while ($row = mysql_fetch_array ($result))
{
$title = $row[&quot;Title&quot;];
$news = $row[&quot;News&quot;];
$date = $row[&quot;Date&quot;];
$sitelink = $row[&quot;SiteLink&quot;];
print (&quot;$title - $date<br>&quot;);
print (&quot;$news<br>&quot;);
print (&quot;<a href=}
?>
 
$query = &quot;SELECT * FROM tblNews LIMIT 0,6&quot;;

That will do the first six.

And so on.

I guess you could do it in a loop where the 0 and 6 are variables, but that would kind of defeat the purpose, unless you do not want to pull out all of the records.

Hope this helps.

-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top