Forum Moderators: coopster
Thanks for the great advice. I have another question. How would I turn the titles of my database news articles into links. I would like for the visitor to click the title, and be taken to the actual page the article is located? Can that be done?
Thanks in Advance,
Senmar
(insert.php script)
<?php
// connect to the mysql server
mysql_connect("localhost","moot","ok") or die (mysql_error());
echo "Connected to Mysql<br/>";
// select the database
mysql_select_db("News_Articles") or die
(mysql_error());
echo "Connected to Database<br/>";
// insert data into ccds_news table
$sql = "INSERT INTO ccds_news(article_title, author_name, subject, date_created, content, EMAIL) VALUES('" . $_POST['article_title'] . "', '" . $_POST['author_name'] . "', '" . $_POST['subject'] . "', '" . $_POST['date_created'] . "', '" . $_POST['content'] . "', '" . $_POST['EMAIL'] . "' )";
// run the query
mysql_query($sql);
echo "DATA ENTERED!";
?>
The php.net tutorial has a page on forms at [be2.php.net...] and you might want to get a book on paper too.
Happy coding!
When any link is clicked, you simply pull data based on the value of 'id' in the query string.
if (isset($_GET['id']))
{
$query = "SELECT FROM table WHERE id = '" . $_GET['id'] . "' LIMIT 1";
//rest of code
}
I would suggest you follow the link that mincklerstraat has posted, it should point you in the right direction.
are you talking about links like this:
www.mysite.com/news/freddie-star-ate-my-hamster.htm
for a story with the title: "freddie star ate my hamster"?
you need to google for 'search engine friendly URLs'. this article by sitepoint is a great starter: [sitepoint.com...] (although it might not work unless you have register_globals on in your php setting.) have a read and come back with questions.
good luck