I have an easy one for you. Unfortunately it is not so easy for me. This is what I am trying to to do. I am running a simple query to extract all agencies in ny:
Now I want to display the results like this:
A
About Artists Agency, Inc.
355 Lexington Avenue, 17th Floor
New York, NY 10017
Phone: (212)490-7191
Abrams Artists Agency
275 Seventh Avenue, 26th Floor
New York, NY 10001
Phone: (646) 486-4600
back to top
B
Barry-Haft-Brown Artists Agency (B-H-😎 (SAG-AFTRA-EQUITY)
165 West 46th Street, Suite 908
New York, NY 10036
(212) 869-9310
Richard Bauman & Associates (SAG-AFTRA-EQUITY)
250 West 57th Street, Suite 2223
New York, NY 10107
(212) 757-0098
back to top
Specifically I want to develop an array that displays the listings with a header of the according letter ("A") then displays all the listings that start with the letter "A". Then when all the A's are finished put an anchored "back to top".
Then all the listings with the letter "B" and so on.
This is what I have so far but it just displays all the listings:
<?//display results
$NumRecords = 0;
while(($row = mysql_fetch_array($result)))
{$NumRecords++;?>
<span class="listing"><b>
<? print $row["CompanyName"]; ?></b><br>
<? print $row["Address"]; ?><br>
<? print $row["City"]; ?>, <? print $row["State"]; ?>
<? print $row["ZIPCode"]; ?><br>
<? if ($row["Phone"]) print "Phone: <font color=\"#cc0033\">" . $row["Phone"] . "</font><br>"; ?>
<? if ($row["Fax"]) print "Fax: <font color=\"#cc0033\">" . $row["Fax"] . "</font><br>"; ?>
<? if ($row["Country"]<>'US') print $row["Country"] . "<br>"; ?>
<? if ($row["EMail"]) print "EMail: <font color=\"#cc0033\"><a href=\"mailto:" . $row["EMail"] . "\">" . $row["EMail"] . "</a></font><br>"; ?>
<? if ($row["WebSite"]) print "WebSite: <font color=\"#cc0033\"><a href=\"http://" . $row["WebSite"] . "\" target=\"_blank\">" . $row["WebSite"] . "</a></font><br>"; ?>
</span>
<?} //end of while loop
if (0 == $NumRecords) print "No talent agencies are currently listed in " . $VLocation . ".<br>";
?>
Thank you in advance.🙂