Table sorting problem

From: Date: Thu, 12 Jan 2006 21:51:29 +0000
Subject: Table sorting problem
Groups: php.db 
Request: Send a blank email to php-db+get-41031@lists.php.net to get a copy of this message
I am a novice in both PHP and MySQL, otherwise I would be able to do this myself. :-) A non-profit I assist has a table (<http://www.lbc4cc.org/04-05board.php>) that is displayed by a simple PHP script. That was fine last year, but now we have some new officers and some new board members and I have no idea how to change the script so that "Officers and Members" table is presented officers first (Pres, Vice-pres, Sec and Treas) and then an alpha listing of board members who are not officers. The existing script looks like this: <?php $sql = "SELECT * FROM members"; $result=mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; }
    echo "<table cellspacing='0' border='1' cellpadding='2'
bgcolor='#FFFFCC' width='100%'>";
    echo "<tr>\n";
    echo "<th>Office</td>\n";
    echo "<th>Name</td>\n";
    echo "<th>Address</td>\n";
    echo "<th>Phones</td>\n";
    echo "<th>Church</td>\n";
    echo "<th>Email</td>\n";
    echo "<th>Term<br>Ends</td>\n";
    echo "</tr>\n";
while ( $row = mysql_fetch_array($result,MYSQL_ASSOC) ) {
    echo "<tr>\n";
if ($row['Office'] == " ") {
    echo "<td>&nbsp;</td>\n";
} else {
    echo "<td><b>{$row['Office']}</b></td>\n";
}
    echo "<td>{$row['Name']}</td>\n";
    echo "<td>{$row['Address']}</td>\n";
    echo "<td>{$row['Phone']}</td>\n";
if ($row['Church'] == "") {
    echo "<td>&nbsp;</td>\n";
} else {
    echo "<td>{$row['Church']}</td>\n";
} if ($row['Email'] == "") {
    echo "<td>&nbsp;</td>\n";
} else {
    echo "<td>{$row['Email']}</td>\n";
}
    echo "<td>{$row['Term']}</td>\n";
    echo "</tr>\n";
} echo "</table>\n"; ?> Can some kind soul bang out the code I need? Thanks.

« previous php.db (#41031) next »