Guest Posted March 4, 2006 Share Posted March 4, 2006 Hi,Am using Dreamwever MX 2004 and trying to create an alphabetical listing menu from a 'countries' Mysql DB. At the moment there are something like 264 countries and I wish for the alphabetical listing to indicate by way of a different font colour, those items that have a country. e.g. the letter 'S' will turn RED if there are any countries in teh database beginning with that letter. When the letter 'S' is clicked the url will invoke a search, pulling all the countries beginning with 'S' into a details page. At this point in time my 'countries'db consists of 5 tables, being ID, cntry_code, flag_loc, map_loc and name.I am using this code below but all I receive is the alphabetical listing at the top of the page. Can anyone help me?[code]<?php require_once('Connections/apt.php'); ?><?phpmysql_select_db($database_apt, $apt);$query_countries = "SELECT DISTINCT UPPER(LEFT (name,1)) FROM countries ORDER BY name ASC";$countries = mysql_query($query_countries, $apt) or die(mysql_error());$row_countries = mysql_fetch_assoc($countries);$totalRows_countries = mysql_num_rows($countries);$alphabet=('A B C D E F G H I J K L M N O P Q R S T U V W X Y Z');$query=mysql_query("select distinct(name) FROM countries");while ($r=mysql_fetch_array($query)) {$initial=$r['name'];$links=str_replace("$name","<a href=\"$test2.php\">$name</a>",$alphabet);}echo("$links");?><body><?phpmysql_free_result($countries);?>[/code] Link to comment https://forums.phpfreaks.com/topic/4114-dynamic-alphabetical-listing-menu/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.