Hello again community,
I am hopefull that someone can look at the following piece of code and see what is wrong. The code pulls the appropriate rows from the database, but for some reason beyond my understanding, it just won't Order the results. The only thing I can think of is that the ordering is to take place before a second 'while' loop, because the same code works on other pages that don't have the first while loop in place. Any help would be appreciated.
<?
//Get the Users
include 'db-customers.php';
$enrolled2=mysql_query("SELECT * FROM 15517ClassHistory WHERE Completed='No'") or die(mysql_error());
$count_rows="0";
while($row2=mysql_fetch_array($enrolled2)){
$studentid = $row2['UserID'];
include 'db-login.php';
if($sortby==""){
$user_get=mysql_query("SELECT * FROM Users WHERE UserID='$studentid' ORDER BY LastName $asc");
}
else{
$user_get = mysql_query("SELECT * FROM Users WHERE UserID='$studentid' ORDER BY $sortby $asc") or die (mysql_error());
}
$row_colors="#C5D8DE";
while ($row = mysql_fetch_array($user_get)) {
$count_rows++;
if ($count_rows%2==0)
{ $row_color="#C5D8DE"; } // Even-numbered rows
else
{ $row_color="#A3DCEC"; } // Odd-numbered rows
$userid = $row['UserID'];
$usernum = $row['InternalID'];
$name = $row['FirstName'] . " " . $row['LastName'];
$email = $row['Email'];
$username = $row['Username'];
$classlevel = $row['ClassLevel'];
//Display the results in the table
echo "
<tr bgcolor=" . $row_color . ">
<td>$userid</td>
<td>$usernum</td>
<td>$name</td>
<td>$classlevel</td>
<td>$username</td>
<td>$email</td>
<td>$count_rows</td>
</tr>
";
} }
?>
Thanks again,
Johnie Karr