Interesting Loop Problem

I have this function, but it doesnt work. Basically the list outputs a list of news features, and puts a line under neath each article to seperate them. However once the last article has been reached, I don’t want the break to be shown.

this is my code, any help would be appreciated as i am really struggling on this. Just need to determine the last item in the array, and stop the


from being output.
This code isnt working, but i have put it here to show what my thinking process is at the moments.
[php]function newsFeature(){
$event = “SELECT imgname, title, content, pkID from news ORDER BY date, time DESC LIMIT 5”;
$event_page = query($event);
$count = numRows($event_page);
while ($row = mysql_fetch_assoc($event_page)) 
{ 
    $rowcount = $count; 
    $para = substr($row['content'] , 0,100); 
    $result .= '<article>'; 
    $result .= '<a href="news-article.php?pkID=' . $row['pkID'] . '"><img src="uploads/thumbs/' . $row['imgname'] . '" alt="" width=116 height=83/ ></a>'; 
    $result .= '<h2><a href="news-article.php?pkID=' . $row['pkID'] . '">' . $row['title'] . '</a></h2>'; 
    $result .= '<p>' . $para . '...</p>'; 
    $result .= '<p><a class="read-more" href="news-article.php?pkID=' . $row['pkID'] . '">Read more<span></span></a></p>'; 
    $result .= '</article>'; 
    if($row != end($row[])){ 
        $result .= '<hr class="split">'; 
    } 
} 
    return $result; 

} [/php]

I would do this way:
[php] for($i=1;$i<=mysql_num_rows($event_page);$i++)
{
$row = mysql_fetch_array($event_page);

    $rowcount = $count; 
    $para = substr($row['content'] , 0,100); 
    $result .= '<article>'; 
    $result .= '<a href="news-article.php?pkID=' . $row['pkID'] . '"><img src="uploads/thumbs/' . $row['imgname'] . '" alt="" width=116 height=83/ ></a>'; 
    $result .= '<h2><a href="news-article.php?pkID=' . $row['pkID'] . '">' . $row['title'] . '</a></h2>'; 
    $result .= '<p>' . $para . '...</p>'; 
    $result .= '<p><a class="read-more" href="news-article.php?pkID=' . $row['pkID'] . '">Read more<span></span></a></p>'; 
    $result .= '</article>'; 
    if($i!=mysql_num_rows($event_page)){ 
        $result .= '<hr class="split">'; 
    } 
}[/php]

[php]
function newsFeature(){
$event_page=mysql_query(“SELECT imgname, title, content, pkID from news ORDER BY date, time DESC LIMIT 5”);
$count = mysql_num_rows($event_page);
$i=‘1’;
while ($row= mysql_fetch_array($event_page))
{
$rowcount = $count;
$para = substr($row[‘content’] , 0,100);
$result .= ‘’;
$result .= ‘’;
$result .= ‘

’ . $row[‘title’] . ‘

’;
$result .= ‘

’ . $para . ‘…

’;
$result .= ‘

Read more

’;
$result .= ‘’;
	if ($i != $count) {
		$result .= '<hr class="split">'; 
	}
	
	$i++;

} 
    return $result; 

}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service