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
https://forums.phpfreaks.com/topic/265124-echo-more-than-one-result/
Share on other sites

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.