Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display problem??

Status
Not open for further replies.

hisham

IS-IT--Management
Nov 6, 2000
194
I have tow tables:
category “ id, name “ and
items: “id, cid, name, details”
where cid in items table = id in category table
and I use the following code to display all category with links to the related items:

<?
$cat = &quot;SELECT * FROM category &quot;;
$result = mysql_query($cat);
$num=mysql_num_rows($result);
for($i=0;$i<$num;$i++){
$row = mysql_fetch_row($result);

echo&quot;<ahref=\&quot;items.php?sid=$row[0]\&quot;>$row[2]</a>&quot;;
}
?>

now. How can I display the name of the category related in the items.php:

<?
$query = mysql_query(&quot;SELECT * FROM items WHERE id='$id'&quot;);
$row = mysql_fetch_row($query);
echo &quot;$row[2]&quot;;
echo &quot;$row[3]&quot;;
?>
 
$query = mysql_query(&quot;SELECT * FROM items WHERE id='$sid'&quot;);

where $SID is the value created by the link in the first bit of code

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top