silverscout Posted January 7, 2008 Share Posted January 7, 2008 I am trying to output a category like a phone book and am getting lost in the loops. Is there any direction or tutorial that can help me? I have used google and so far it has failed me. Basically what I want is when someone click A.. they would get somethig like this. I have the buttons worked out for when they click A it outputs all the Categories that start with an A. HOwever, to sort them into category and output it like below is confusing me. any push into the right direction would be much appreciated. Auto "list of companites under auto" Advertising "list of companies under advertising" Like how you would find in a phonebook. Quote Link to comment https://forums.phpfreaks.com/topic/84818-category-outputing/ Share on other sites More sharing options...
rajivgonsalves Posted January 7, 2008 Share Posted January 7, 2008 post your code ? Quote Link to comment https://forums.phpfreaks.com/topic/84818-category-outputing/#findComment-432386 Share on other sites More sharing options...
mmarif4u Posted January 7, 2008 Share Posted January 7, 2008 Yeh its better to post your code,that we try to help you out. Quote Link to comment https://forums.phpfreaks.com/topic/84818-category-outputing/#findComment-432387 Share on other sites More sharing options...
silverscout Posted January 7, 2008 Author Share Posted January 7, 2008 This is the current code. I have been looking for ways to output the categories and finding ways through google but can not find anything. Thus why I am asking fora push in the right direction here. <?php include("api.php"); db_link($dbhost, $dbuser, $dbpass, $dbase); if(isset($_GET['id'])) { $query_results = mysql_query("SELECT bname, contact, address, city, state, zip, phone, fax, url, email, member FROM business_reg WHERE member = 1 and bname LIKE '".mysql_real_escape_string($_GET['id'])."%' ORDER BY bname"); //$output = mysql_result($query_results); } ?> then the output is here.. <?php if(isset($_GET['id'])) { while(list($bname, $contact, $address, $city, $state, $zip, $phone, $fax, $url, $email) = mysql_fetch_row($query_results)) { echo "<font size=4 face=sans-serif><b>$bname</b></font> <br /> <font size=3 face=sans-serif>$contact </font><br /><font size=3 face=sans-serif>$address </font><br/><font size=3 face=sans-serif> $city, $state $zip </font><br /><font size=3 face=sans-serif>Phone: $phone </font><br/><font size=3 face=sans-serif>Fax: $fax </font><br /><font size=3 face=sans-serif><a href='http://$url'>$url</a> </font><br /><font size=3 face=sans-serif>$email </font><br /> <hr> </font><br />"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84818-category-outputing/#findComment-432406 Share on other sites More sharing options...
Barand Posted January 7, 2008 Share Posted January 7, 2008 try <?php include("api.php"); db_link($dbhost, $dbuser, $dbpass, $dbase); if(isset($_GET['id'])) { $query_results = mysql_query("SELECT bname, contact, address, city, state, zip, phone, fax, url, email, member FROM business_reg WHERE member = 1 and bname LIKE '".mysql_real_escape_string($_GET['id'])."%' ORDER BY bname, contact"); //$output = mysql_result($query_results); } ?> then the output is here.. <?php if(isset($_GET['id'])) { $lastBName = ''; while(list($bname, $contact, $address, $city, $state, $zip, $phone, $fax, $url, $email) = mysql_fetch_row($query_results)) { if ($bname != $lastBName) { echo "<font size=4 face=sans-serif><b>$bname</b></font> <br /> "; $lastBName = $bname; } echo "<font size=3 face=sans-serif>$contact </font><br /><font size=3 face=sans-serif>$address </font><br/><font size=3 face=sans-serif> $city, $state $zip </font><br /><font size=3 face=sans-serif>Phone: $phone </font><br/><font size=3 face=sans-serif>Fax: $fax </font><br /><font size=3 face=sans-serif><a href='http://$url'>$url</a> </font><br /><font size=3 face=sans-serif>$email </font><br /> <hr> </font><br />"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84818-category-outputing/#findComment-432492 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.