Jump to content


Photo

Filter Results


  • Please log in to reply
No replies to this topic

#1 ramblas

ramblas
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 May 2006 - 06:10 AM

Hi
I have a Mysql Db with Tables:
Table category:
cat_id
category

Table subcategory:
subcat_id
cat_id
subcategory

Table url
some fields plus
url_category (txt)
url_subcategory (txt)

I am querying the Database from the main page to select all Subcategies and get this on the Result Page (works fine)
<?

$query1 = sprintf("SELECT * FROM subcategory WHERE cat_id=$id");
$result1=mysql_query($query1);
$total1=mysql_num_rows($result1);
if($total1)
{
echo"<table width=100% cellpadding=0
cellspacing=2 border=1 bordercolor=1>";
$i=0;
while($row1=mysql_fetch_array($result1))

{
if($i%3==0)
echo"<tr>";
echo"<td>".


"<a href=viewsubcat.php?id=" . $row1["subcat_id"] . ">" . $row1["subcategory"] . "</a>".
"</td>"; $i++;
if($i%3==0)


echo"</tr>";
}

{
}

echo"</table>";
}
?>

This shows all the Subcategories Then I want to query this and show all the URL with this Subcategory (from Table URL) I am doing it like this (does not work)<?
$query1 = sprintf("SELECT * FROM url WHERE url_subcategory=$id");

//$query1="select * from url WHERE subcategory=$id";
$result1=mysql_query($query1);
$total1=mysql_num_rows($result1);
if($total1)
{
echo"<table width=100% cellpadding=2
cellspacing=2 border=1 bordercolor=1>";
$i=0;
while($row1=mysql_fetch_array($result1))
//{echo "<a href=details.php?id=" . $a_result1["category"] . ">" . $a_row1["category"] . "</a><br>\n";
//}

{
if($i%3==0)
echo"<tr>";
echo"<td>".$row1["url_title"]."</td>";$i++;
if($i%3==0)


echo"</tr>";
}

{
}

echo"</table>";
}
?>

This is a type of Search engine I am trying to do where Customer clicks on Main Category then corresponding Subcategory and then should see a Results page with Entries in that Subcategory (The URL Table has Category and Subcategory (text) as entered by Visitors from drop down box. Could some one help with the correct code for the last Results Page?Much appreciated
Regards
Manfred (Jeffreys Bay)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users