Hello All
I lurked around the forums but did not see an answer to this question. I need to create a company directory with A-Z links across the top with anchors for each letter so that when a letter is clicked the list scrolls to that letter. Like So:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
A (anchor)
A Company 1
A Company 2
A Company 3
B (anchor)
B Company 1
B Company 2
B Company 3
And so on. I found a great example of how to build the A-Z now how do I efficiently set up a loop to crank out the directory? Thanks in advance
Regards
Russ
ps here is the A-Z Code:
<?php
//Database Connection String
$hostname = “server_localhost”;
$database = “database_name”;
$username = “user_name”;
$password = “password”;
$connection1 = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
//Data Extraction
mysql_select_db($database, $connection1);
$query_AZList = “SELECT DISTINCT UPPER(LEFT(company_name,1)) as letters FROM company_dir ORDER BY letters”;
$AZList = mysql_query($query_AZList, $connection1) or die(mysql_error());
$row_AZList = mysql_fetch_assoc($AZList);
$totalRows_AZList = mysql_num_rows($AZList);
?>
// Displaying the result by looping using PHP
<?php do { ?>
<?php echo ‘<a href=”list.php?ltr=’.$row_AZList[’letters’].’”>’.$row_AZList[’letters’].’</a>’; ?>
<?php } while ($row_AZList = mysql_fetch_assoc($AZList)); ?>