php news website

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
candyman
Forum Newbie
Posts: 2
Joined: Thu Sep 29, 2011 4:52 pm

php news website

Post by candyman »

Hello,

I am new in programming in PHP and I have small problem(for me it is big :D). 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 :D

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'];

}



?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: php news website

Post by Celauran »

What isn't working?
candyman
Forum Newbie
Posts: 2
Joined: Thu Sep 29, 2011 4:52 pm

Re: php news website

Post by candyman »

I do not know, they cannot produce output to the web page.
Post Reply