hi guyz, i'm developing my own website, when creating news, i'm having this problem, i can't show news by id, i mean i have 5 news item in my db and they are stored by id 1,2,3,4,5... but when it comes to display the news they all display as a block, even when i browse it by id like: localhost/news/news.php?id=3, it shows all the news items, instead of third news??

somebody help plz

hi guyz, i'm developing my own website, when creating news, i'm having this problem, i can't show news by id, i mean i have 5 news item in my db and they are stored by id 1,2,3,4,5... but when it comes to display the news they all display as a block, even when i browse it by id like: localhost/news/news.php?id=3, it shows all the news items, instead of third news??

somebody help plz

You call the news from the database selecting the id so for example

$id = $_GET['id'];

$sql = ("SELECT * FROM `news` WHERE id='$id'");
$res = mysql_query($sql);

while ($row = mysql_fetch_array($res)){

echo $row['title'];
echo "<br>";
echo $row['news'];
}

That should (depending on your database row names ) call the title and the news from your database.

Hope it helps...

hi, thanx for answer, but it doesn't solve the problem, i attached my codes a long with database file, it will be more clear i hope

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.