displaying sorted data
Posted: Sun Feb 02, 2003 5:48 pm
Does anyone know of a good method for sorting things by letter. I have a script with many reviews of different shows in it. I would like to be able to sort them a-g, h-j, k-m (you get the picture)
i came up with this method
$split is the letter to stop displaying data at and this works, but i have not the slightest how to do something that would let me say start at "C" and stop at "S". If there is no way to do this through variables, I would settle for hard coding the sorting methods in to just being a-g, h-k strictly. If there is a way to do this through a query please share.
Matt
i came up with this method
Code: Select all
$query = reg_query("SELECT * FROM reviews ORDER BY name ASC");
// Output The List
while ($data = fetcho_query($query)) {
if (substr($dataї'name'],0,1) == strtoupper($split)) break;
// Make overall rating
$rating = round(($dataї'rating_animation'] + $dataї'rating_characters'] + $dataї'rating_music'] + $dataї'rating_plot'] + $dataї'rating_sound'] + $dataї'rating_voiceacting']) / 6, 1);
$date = date("n/j/Y", $dataї'revid']);
$search = array('<LISTBIT: Name>', '<LISTBIT: Genre>', '<LISTBIT: Type>', '<LISTBIT: Date>', '<LISTBIT: Rating>', '<LISTBIT: ID>');
$replace = array($dataї'name'], $dataї'genre'], $dataї'type'], $date, $rating, $dataї'revid']);
$list_reviews .= str_replace($search, $replace, stripslashes($keybaseї'review_listbit']));
}Matt