ramblas Posted May 10, 2006 Share Posted May 10, 2006 Hi I have a Mysql Db with Tables:Table category:cat_idcategoryTable subcategory:subcat_idcat_idsubcategoryTable urlsome fields plusurl_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 appreciatedRegardsManfred (Jeffreys Bay) Quote Link to comment https://forums.phpfreaks.com/topic/9448-filter-results/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.