View Full Version : Using row id to rest of row.

08-20-2007, 08:25 AM
How would yo go about doing this?
What i mean is if you had 3 columns (auto generated id, name, age)
and you just wanted to call the id and have the rest of the row display
when that id is called.

Ex.) Table structure

How would you echo the subject and content of a row by
using the id to choose the row, Such as using news.php?article=2
and it would echo subject2 and content2.

-Thanks for the help

edit: messed the post title up :/

08-20-2007, 08:50 AM

$id = $_GET['id'];

$sql = mysql_query("SELECT * FROM tablename WHERE id='$id'") or die(mysql_error());
while ($row = mysql_fetch_array($sql)){
$name = $row['name'];
$age = $row['age'];
echo $name;
echo $age;