按特色DESC排序不适用于自定义变量

I have the following functions , I need to update $how so it sort videos by featured videos after the site_views DESC I tried a lot of times but same output is displaying or I get empty output.Thanks in advance. so i need to display only featured videos after site_views.

function list_videos($how = 'added', $limit = '15') { // newest, top views, etc etc etc
    $query = mysql_query("SELECT * FROM pm_videos ORDER BY $how DESC LIMIT $limit");
    $result = '';
    while ($row = mysql_fetch_array($query)) {

        $results .= "
                <div class=\"item\">
                <a href=\"" . makevideolink($row['uniq_id'], $row['artist'], $row['video_title']) . "\"><img src=\"" . show_thumb($row['uniq_id']) . "\" alt=\"" . $row['video_title'] . "\" class=\"imag\" width=\"107\" height=\"72\" /></a>
                <a href=\"" . makevideolink($row['uniq_id'], $row['artist'], $row['video_title']) . "\" class=\"song_name\">
                <span class=\"artist_name\">" . fewchars($row['artist'] . " - " . $row['video_title'], 30) . "</span>
                </a>
                <span class=\"item_views\">" . pm_number_format($row['site_views']) . " views</span>
                </div>";
    }
    return $results;
}

Well now i updated the code and it's showing featured vidos only but they aren't ordered:

function list_featured_videos($how = 'added', $limit = '15') { // newest, top views, etc etc etc
    $query = mysql_query("SELECT *
FROM `pm_videos`
ORDER BY `pm_videos`.`featured` DESC
LIMIT 0 , 30");
    $result = '';
    while ($row = mysql_fetch_array($query)) {

        $results .= "
                <div class=\"item\">
                <a href=\"" . makevideolink($row['uniq_id'], $row['artist'], $row['video_title']) . "\"><img src=\"" . show_thumb($row['uniq_id']) . "\" alt=\"" . $row['video_title'] . "\" class=\"imag\" width=\"107\" height=\"72\" /></a>
                <a href=\"" . makevideolink($row['uniq_id'], $row['artist'], $row['video_title']) . "\" class=\"song_name\">
                <span class=\"artist_name\">" . fewchars($row['artist'] . " - " . $row['video_title'], 30) . "</span>
                </a>
                <span class=\"item_views\">" . pm_number_format($row['site_views']) . " views</span>
                </div>";
    }
    return $results;
};

and calling it with :

$featured = list_featured_videos('added');

Note that using added or site_views rendered the same result.

As seen in your previous question, you need a new, separate function for the display of featured videos:

Edited as requested:

function list_featured_videos($sql) { // newest, top views, etc etc etc
    $query = mysql_query( $sql );
    $result = '';
    while ($row = mysql_fetch_array($query)) {

        $results .= "
                <div class=\"item\">
                <a href=\"" . makevideolink($row['uniq_id'], $row['artist'], $row['video_title']) . "\"><img src=\"" . show_thumb($row['uniq_id']) . "\" alt=\"" . $row['video_title'] . "\" class=\"imag\" width=\"107\" height=\"72\" /></a>
                <a href=\"" . makevideolink($row['uniq_id'], $row['artist'], $row['video_title']) . "\" class=\"song_name\">
                <span class=\"artist_name\">" . fewchars($row['artist'] . " - " . $row['video_title'], 30) . "</span>
                </a>
                <span class=\"item_views\">" . pm_number_format($row['site_views']) . " views</span>
                </div>";
    }
    return $results;
};

Now you can call this using

$featured = list_featured_videos('SELECT * FROM pm_videos WHERE featured=1 ORDER BY site_views DESC LIMIT 10');

for example.

Changing:

 $query = mysql_query("SELECT * FROM pm_videos ORDER BY $how DESC LIMIT $limit");

to

$query = mysql_query("SELECT * FROM pm_videos ORDER BY site_views DESC LIMIT $limit");

Should work based on what can be seen there (your code currently orders by added DESC) in your example code.........

Is this one of the combinations you've tried?

$featured = list_featured_videos('SELECT * FROM pm_videos  WHERE featured="1" ORDER BY site_views DESC LIMIT 10');