...

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



JustBlaze
08-20-2007, 09: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
|id|subject|content|
|1|subject1|content1|
|2|subject2|content2|

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 :/

MHaris
08-20-2007, 09:50 AM
<?php

$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;
}

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum