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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.