Creating Alphabetical links to records

Hi guys,

I am building a directory of company addresses. I want to be able to allow users to select links from a list of alphabets, where the alphabet represents the first first letter of the name they are looking for. This link will direct them to a list of companies with name starting with the alphabet clicked.

Here is my code:

mysql_select_db($database_directory, $directory);
$query_mda = "SELECT name FROM company ORDER BY name ASC";
$mda = mysql_query($query_mda, $directory) or die(mysql_error());
$row_mda = mysql_fetch_assoc($mda);
$totalRows_mda = mysql_num_rows($mda);

Thanks for your help :slight_smile:

Hi,
Try use this select:


$name = 'the_name';
$first_in_name = $name{0};
$query_mda = "SELECT name FROM company WHERE SUBSTRING(name, 0, 1)='$first_in_name' ORDER BY name ASC";