按字母顺序列出下拉框

按字母顺序列出下拉框

问题描述:

I want order my activityComboHtml alphabetically. Any help would be appreciated.

static function GetInnerContent()
{
    $activityComboHtml=Page::getActivityTitles();
    $ageComboHtml=Page::getAgeComboHtml();
    $displayBanner="";
    $bannerUrl=Page::fetchAllOrganizaitonBanners();
    $staticBanner=  HelpingDBMethods::getStaticBanner();
    if($bannerUrl=="-1")
    {
        $displayBanner="style='display:none'";

    }
    return 

Here is the static function

 static function getActivityTitles(){
    $html="";
    $Query="Select uniqueId, name from tbl_activity_type_general where NOT(uniqueId = '12')";
    $result=  mysql_query($Query);
    if($result)
    {
        while($row=  mysql_fetch_assoc($result))
            {
             $html=$html."<option id='".$row['uniqueId']."' value='".$row['uniqueId']."'>".$row['name']."</option>";
            }
    }

Change your SQL query to

SELECT `uniqueId`, `name`
FROM `tbl_activity_type_general`
WHERE NOT( `uniqueId` = '12' )
ORDER BY `name` ASC

So, the statement becomes:

$Query="SELECT `uniqueId`, `name` FROM `tbl_activity_type_general` WHERE NOT( `uniqueId` = '12' ) ORDER BY `name` ASC";