Jump to content

Recommended Posts

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>";
}
?>

[b]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)[/b]<?
$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)
Link to comment
https://forums.phpfreaks.com/topic/9448-filter-results/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.