Jump to content

Display only mysql_num_rows results #-# (or similar)


br3nn4n

Recommended Posts

This is probably really really simple, but I can't get it to work on my end...haha.

 

So I have this mysql database. It works great, the stuff outputs how I want. But I'm making a news website and I need to change the articles each month.

 

I'm putting all the articles into one database, then into each page as tables (ie: news, opinion, sports, etc.), then the articles each have their own row. On the homepage here it outputs all 5 articles from the news table, but I only want it to output result numbers (blah) through (whatever).

 

Here's the code used on the page to output the 5:

<?
$query1 = mysql_query("SELECT * FROM news");

while ($result1 = mysql_fetch_array($query1)) {
for ($i = 0; $i < mysql_num_rows($query1) {
echo "<a href=\"index.php?page=news&article=$result1[id]\"><b>$result1[title]</b></a>";
echo "<br /><i>$result1[date]</i>";
echo "<br />By <i>$result1[name]</i>";
echo "<br />$result1[desc]";
echo "<br><br>";
break;
$i++;
}
}
?>

 

I'm only recently getting into dynamic coding (ie: php) and these forums have been a lot of help with other things, so thanks in advance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.