When I use the code below in a file to publish news on my website, it goes all weird.

Basically, the latest newsid post is displayed at the top as it should be. However, underneath that, instead of more newsposts being displayed, the entire page is repeated again (such as the entire header, logo and page start etc) with the latest posts displayed at the top down to the first post.

Then under that it continues again, for as many news posts as there have been. For exmaple, 4 news posts and the page is looped for times. 3 news posts and it is looped 3 times.

Like this:

-- Header --
- News (ID: latest entry)
-- Footer --

-- Header --
- News (ID latest entry)
- News (ID 2nd from latest entry)
- News (ID first entry)
-- Footer --

-- Header --
- News (ID latest entry)
- News (ID 2nd from latest entry)
- News (ID first entry)
-- Footer --

Since there are 3 posts, the page is looped like this. if there are four posts it is looped like below:

-- Header --
- News (ID: latest entry)
-- Footer --

-- Header --
- News (ID latest entry)
- News (ID 2nd from latest entry)
- News (ID first entry)
-- Footer --

-- Header --
- News (ID latest entry)
- News (ID 2nd from latest entry)
- News (ID first entry)
-- Footer --

-- Header --
- News (ID latest entry)
- News (ID 2nd from latest entry)
- News (ID first entry)
-- Footer --




*** I am using the script below. ***

PHP Code:
<?php


$db_name 
"dbname";

$table_name "news2";

$connection mysql_connect("localhost""username""password") or die(mysql_error());

$db mysql_select_db($db_name$connection) or die(mysql_error());

if (
$show == "all")

{

$sql "SELECT * FROM $table_name ORDER BY title";

$result mysql_query($sql$connection) or die(mysql_error());

while (
$row mysql_fetch_array($result)) {

$newsid $row['newsid'];
$title stripslashes($row['title']);
$postedby stripslashes($row['postedby']);
$date stripslashes($row['date']);
$contact stripslashes($row['contact']);
$description stripslashes($row['description']);





$display_block .= "<tr><td width=\"20%\" valign=\"top\"><b>$postedby</b><br><a href=\"mailto:$contact\">$contact</a></td><td width=\"80%\"><b>$title - Posted on: $date - <a href=\"mailto:$contact\">Email Poster</a> - <a href=\"edit.php?action=edit&id=$newsid\">Edit</a> - <a href=\"delete.php\">Delete</a></b><hr width=\"93%\" align=\"center\"><br><b><a href=?action=showmore&newsid=$newsid>$title</a><br><br>$description<br><br></td></tr>";

echo 
"<html><head><title>Huh</title><body><table width=\"700\" align=\"center\">$display_block</table></body></html>";

}

}



?>
Anyone know whats going on with this script. I have a feeling its the WHILE and LOOP playing up, but I haven't the faintest clue.

Can anyone help?

For anyone wondering I removed the &action=showmore&newsid=$newsid code section becuase it is irellevant to the post.