Table sorting problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux