Forum Moderators: coopster
I concidered starting new website as a part of my "business". It is about commenting and reviewing devices like VCR, camcorders, phones, DVD, computers and lot else.
Problem is that i planned to make database like:
database
- laitekatsaus_articles
-- COLUMNS: id, email, name, date, ip, rating...
- laitekatsaus_comments (these are comments for users articles)
-- COLUMNS: id, articleid, name, date, ip...
I plannes to make it list the article names to a list. All those article names are links leading to the full articles. so... if there is article name in the list... lets say article id 1.
It has a link <a href="MYURL/viewarticle.php"></a>
How do i need to modify that if i want it to print on screen ONLY the row that has the id of the link in table LAITEKATSAUS_ARTICLES.
Should it be like <a href="MYURL/viewarticle.php?id=1"></a>
If it is like that, what do i need to do for the viewarticle.php's mysql query?
All help is appreciated
<?php
// include your script with the db connection
require_once('db_connect.php');
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$rs = mysql_query("SELECT *
FROM laitekatsaus_articles
WHERE id = $_GET[id]");
// rest of the script
It's probably easiest to get the comments in a separate query.
Anyway, I hope I'm not being rude, but it sounds like you could need a starters course in PHP and MySQL. Buy a book, Google for 'php tutorial', and dig through the archives of this forum!
Most people find it handy to have one file that handles the connection to the database - mysql_connect() - and the selection of the database - mysql_select_db(). Simply include it when necessary, and you won't have to bother with remembering passwords et cetera.