php news website
Posted: Thu Sep 29, 2011 5:08 pm
Hello,
I am new in programming in PHP and I have small problem(for me it is big
). I am developing one web site and in that web site users have ability to look at new news and when click on name of that news, that news needs to be opened in new page called news.php. I will show to you my code and I hope so that you will find solution for this peace of code 
The index.php page looks like this:
<?php
$result = mysql_query("SELECT * FROM pages ORDER BY id DESC LIMIT 10");
while ($page = mysql_fetch_array($result)) {
echo "<a href=\"news.php?page=" . urlencode($page["id"]) . "\" class='news'>{$page["newsname"]}</a><br />";
echo "<h5 style=' font-size: 10px; color: black;'>{$page["date"]}</h5><hr style='margin: 5px auto 5px;' />";
}
?>
This is index page where we have list of new news!
Here is page which needs to open content of that news:
news.php
<?php
if (isset($_GET['id']))
{
$result = mysql_query("SELECT id, newsname, text FROM pages WHERE `id`='".$_GET['id']."'");
$page = mysql_fetch_array($result);
echo $page['newsname']."<br />".$page['tekst'];
}
?>
I am new in programming in PHP and I have small problem(for me it is big
The index.php page looks like this:
<?php
$result = mysql_query("SELECT * FROM pages ORDER BY id DESC LIMIT 10");
while ($page = mysql_fetch_array($result)) {
echo "<a href=\"news.php?page=" . urlencode($page["id"]) . "\" class='news'>{$page["newsname"]}</a><br />";
echo "<h5 style=' font-size: 10px; color: black;'>{$page["date"]}</h5><hr style='margin: 5px auto 5px;' />";
}
?>
This is index page where we have list of new news!
Here is page which needs to open content of that news:
news.php
<?php
if (isset($_GET['id']))
{
$result = mysql_query("SELECT id, newsname, text FROM pages WHERE `id`='".$_GET['id']."'");
$page = mysql_fetch_array($result);
echo $page['newsname']."<br />".$page['tekst'];
}
?>