Jump to content

ramblas

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ramblas's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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)
  2. HI Thanks so much for the Answer Works very well Complete Code (as i use it) below in case somebody else has the same Query <? $query1="select * from category "; $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=details.php?id=" . $row1["cat_id"] . ">" . $row1["category"] . "</a>". "</td>"; $i++; if($i%3==0) echo"</tr>"; } { } echo"</table>"; } ?> This will show Categories from Mysql Table in a 3 Column Table With Kind Regards Manfred (South Africa)
  3. Hi I have been trying to set up a Multi Column display following the Tutorial but would like the displayed results linked to another Detail Page (similar to a Yahoo Style Category List (with Sub Cats if possible) The Code below works fine displaying my Categories in 3 Columns and I found another script somewhere else which also does that and hyperlinks the Results but the Layout is not as nice.Been trying to combine the 2 Codes to get the desired Result but no luck. START OF FIRST CODE (works fine but not linked to Details Page which I would Like) Second Code which links is below My Question is therefor : How can the below code be modifed so that the displayed Results can be clicked on? <?php // set your infomation. $dbhost='localhost'; $dbusername='****'; $dbuserpass='****'; $dbname='*****'; // connect to the mysql database server. $link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass); // select the specific database name we want to access. $dbname=$dbusername."_".$dbname; if (!mysql_select_db($dbname)) die(mysql_error()); ?> <? $query1="select * from category "; $result1=mysql_query($query1); $total1=mysql_num_rows($result1); if($total1) { echo"<table width=800 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["category"]."</td>";$i++; if($i%3==0) echo"</tr>"; } { } echo"</table>"; } ?> START OF SECOND CODE (Works with Clicks but layout is not what I need) <?php //This is a working script //Make sure to go through it and edit database table filelds that you are seraching //This script assumes you are searching 3 fields $hostname_logon = "localhost" ; $database_logon = "*****" ; $username_logon = "******" ; $password_logon = "*****l" ; //open database connection $connections = mysql_connect($hostname_logon, $username_logon, $password_logon) or die ( "Unabale to connect to the database" ); //select database mysql_select_db($database_logon) or die ( "Unable to select database!" ); $query = mysql_query("SELECT * FROM category"); while ($a_row=mysql_fetch_array($query)) { echo "<a href=details.php?id=" . $a_row["cat_id"] . ">" . $a_row["category"] . "</a><br>\n"; } ?>
×
×
  • 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.