Jump to content

Echo More Than One Result


justlukeyou

Recommended Posts

Hi,

 

I have set an article system for my site.  However, whenever I select a category it only displays the first article.  If I have 3 articles under "football" it only displays the first article.

 

This is the code I have to Get the article category.

 

 

<?php
if (isset($_GET['articlecategory']))
$articlecategory = mysql_real_escape_string($_GET['articlecategory']);
$sql = "SELECT * FROM articles WHERE articlecategory = '$articlecategory' ORDER BY ID DESC LIMIT 15";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res); // no need to loop since you are retrieving only one row
$num_rows = mysql_num_rows($res); // check to see if any results were found, just in case someone puts an ID in the url without clicking on your link
?>

 

This is the code I am using to echo the articles in.  Any suggestions please?

 

<div class="articlesborder">


<div class="articlestitleborder"><a href="http://ukhomefurniture.co.uk/articles/article/<?php echo $row['ID']; ?>" class='articleslink' rel="nofollow" ><?php echo $row['title']; ?></a></div>

<div class="articlesintroborder"><?php echo $row['intro']; ?></div>

<div class="articlesdateborder"><?php echo $row['date']; ?></div>

<div class="articlesintroborder"><?php echo $row ['articlecategory']; ?></div>


<div class="articlescontentborder"><?php echo $row['articleintro']; ?></div>

<div class="articlesimageborder"><a href="http://ukhomefurniture.co.uk/articles/article/<?php echo $row['ID']; ?>" rel="nofollow" ><img src="<?php echo $row['image']; ?>" /></a></div>

</div>

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.