ramblas Posted May 5, 2006 Share Posted May 5, 2006 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";}?> Quote Link to comment https://forums.phpfreaks.com/topic/9122-multi-column-display-link-to-details/ Share on other sites More sharing options...
onepixel Posted May 5, 2006 Share Posted May 5, 2006 You can use the FIRST CODE to display clickable categories by replacing the line:echo"<td>".$row1["category"]."</td>";$i++;by echo"<td>"."<a href=details.php?id=" . $a_result1["category"] . ">" . $a_row1["category"] . "</a>"."</td>"; $i++; Quote Link to comment https://forums.phpfreaks.com/topic/9122-multi-column-display-link-to-details/#findComment-33640 Share on other sites More sharing options...
ramblas Posted May 6, 2006 Author Share Posted May 6, 2006 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 TableWith Kind RegardsManfred (South Africa) Quote Link to comment https://forums.phpfreaks.com/topic/9122-multi-column-display-link-to-details/#findComment-33805 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.