Jump to content

category Outputing


silverscout

Recommended Posts

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. 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
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.