pulling sql data within a while loop
Posted: Tue Oct 12, 2010 10:46 am
Goal here is to get the id's then pull the names of each of the id's from a different table. This works great until the result = db->query from within the while loop. When i apply that i only get 1 result, instead of 7 which is how many rows are really in the db.
Any input is appreciated.
Thanks,
Any input is appreciated.
Thanks,
Code: Select all
$db = new MySQL();
$result = $db->query("SELECT id FROM users WHERE user_id <> '$user_id'");
while($row = $db->FetchArray($result)) {
$id = $row['id'];
$result =$db->query("SELECT * FROM chains WHERE id = '$id'");
var_dump($chain_result);
$row1 = $db->FetchArray($result);
$desc = $row1['description'];
$name = $row1['name'];
echo $id;
echo "Name: " . $name . " <a href=\"#\" class=\"joinChain\">Join Chain</a>";
echo "<form method=\"post\" action=\"\"><input type=\"hidden\" class=\"id\" value=\"". $id . "\">";
echo "<br /> Description: " . $desc;
echo "<br /><br />";
}