Sub Queries with MySQL

admin

Administrator
Staff member
I have two tables one holding categories one holding links.

I want to list each category and each link for that category.

I have a category id field in both tables but i can't seem to pass the 'select from where' to the second query.

Helppp !!

The script so far is as below :-

$categories = mysql_db_query($db,"SELECT * FROM categories ORDER BY category",$cats) or die ("category fail");

while ($cat = @mysql_fetch_array($categories)) {
echo "<tr><td COLSPAN = '3'><b>",$cat['category'],$cat['id'],"</b></TD></tr><ul>\n";
$searchfor = $cat['id'];
$result = mysql_db_query($db,"SELECT * FROM links WHERE category = "+$searchfor,$link);

while ($row = @mysql_fetch_array($result)) {
echo "<tr><td><LI><a href = 'http://www.phpbuilder.com/board/archive/index.php/",$row['wwwlink'], "'><font size = '3'>", $row['wwwtext'], "</font></a></LI</td><td>", $row['wwwdesc'], "</td><td>",$row['category'],"</TD></tr>\n";
}
}
 
Back
Top