Hi. I have problems sorting this. Can anyone help me? I would like my output to be in alphabetical order by the name of Game (column - Game). My code below works but for each table in alphabetically only and since the output consists of more than one table, it starts sorting again for the next table which means the overall output isn't sorted. I'm using this with PHPLib Template and PHPLib dB class
Code:
$tables = array("PlaystationAction", "PlaystationAdventure", "PlaystationFighting", "PlaystationPlatform", "PlaystationPuzzle", "PlaystationRacing", "PlaystationRpg", "PlaystationSimulation", "PlaystationSports", "PlaystationStrategy");
foreach ($tables AS $table) {
$sql = "SELECT Alpha, Game, Url, Date, Publisher, Developer FROM $table
WHERE Alpha='a' ORDER BY Game ASC";
$db->query($sql);
while ($db->next_record()) {
$Alpha = $db->f(Alpha);
$Game = $db->f(Game);
$Url = $db->f(Url);
$Date = $db->f(Date);
$Publisher = $db->f(Publisher);
$Developer = $db->f(Developer);
$color = ($i++ % 2 ) ? '#000000' : '#333333';
$tmp3 = "<tr bgcolor='$color'><td><a href='http://www.phpbuilder.com/$Alpha/$Url/index.phtml'>$Game</a></td><td>$Publisher</td><td>$Developer</td><td>$Date</td></tr>";
$t->set_var('data', $tmp3);
$t->parse('DBlock', 'DataBlock', true);
}
}
Code:
$tables = array("PlaystationAction", "PlaystationAdventure", "PlaystationFighting", "PlaystationPlatform", "PlaystationPuzzle", "PlaystationRacing", "PlaystationRpg", "PlaystationSimulation", "PlaystationSports", "PlaystationStrategy");
foreach ($tables AS $table) {
$sql = "SELECT Alpha, Game, Url, Date, Publisher, Developer FROM $table
WHERE Alpha='a' ORDER BY Game ASC";
$db->query($sql);
while ($db->next_record()) {
$Alpha = $db->f(Alpha);
$Game = $db->f(Game);
$Url = $db->f(Url);
$Date = $db->f(Date);
$Publisher = $db->f(Publisher);
$Developer = $db->f(Developer);
$color = ($i++ % 2 ) ? '#000000' : '#333333';
$tmp3 = "<tr bgcolor='$color'><td><a href='http://www.phpbuilder.com/$Alpha/$Url/index.phtml'>$Game</a></td><td>$Publisher</td><td>$Developer</td><td>$Date</td></tr>";
$t->set_var('data', $tmp3);
$t->parse('DBlock', 'DataBlock', true);
}
}