Nils Olofsson wrote:
><? php
>$id1=$HTTP_GET_VARS['id'];//global vars are turned off.
>//query
> $query="SELECT * FROM news_posts WHERE id=$id1";
> $result=mysql_query($query) or die (mysql_error());
>>while($row = mysql_fetch_array($result)){
>echo $row['title'];
>echo $row['news'];
>}
>>I took out the html formating as its not important.
>There are about 5 records in the table but what happens is that
>it goes through the while loop spitting out everything
>as if i saild "select * FROM news_posts"
>if i change to variables to query1,result1 in page two it only show
>what i asked for.
>>
I know this doesn't explain the anomaly, but why are you using a loop to
display what should be just one result?
The above could be done easily as:
<?
$query='select * from news_posts where id="'.$_GET['id'].'"';
$result=mysql_query($query);
$row=mysql_fetch_array($result);
echo htmlspecialchars($row['title']).'<br />';
echo htmlspecialchars($row['news']);
?>
Kae
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!