How would I create a news system?
I have a database where I can create a news article through PHPMyAdmin with the fields: "Name of the article", "Content", "Writer".
I have already made a "latest news" system, which looks like this:
$result = mysql_query("SELECT * FROM news LIMIT 5");
if(mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result))
{
echo $row['Namn'];
echo " av ";
echo $row['Skribent'];
echo "<br />";
}
}
mysql_close($con);
?>
And that is the latest news system (skribent means = writer), (namn means = name (of the article), (av means = by),.
开发者_开发百科So, now I have two problems. Once these news are displayed, I want them to be clickable and once you click it, you get to the original page where the article is located, how do I do it?
And, how do I do so that when I insert a query it will automatically create a nice page for every article, like most famous sites have. When they create a news it comes like http://google.com/news/how-to-be-a-dork/
Firstly to link articles to a different page you could use the element's onclick method, and use javascript to redirect the user, or you could add <a>
tag around the article element.
Secondly, if you would like pretty urls you will have to read up on url re-writing, I unfortunately don't know much about it.
精彩评论