Why is my while() loop not returning one of the rows? The row varies when i sort by different names. Any suggestions? I just started learning PHP, so any help would be great.
<?
/admin/usermanagement.php
#
include("../../includes/connect.inc");
#include("../../includes/disabled.inc");
phphreak_connect ()
or exit ();
include("../../includes/header.inc");
include("../../includes/admin.inc");
if($admin == "1") {
if($sort == "firstname") {
$result = mysql_query("SELECT FROM phphreak_users ORDER BY first_name");
$myrow = mysql_fetch_row($result);
}
elseif($sort == "lastname") {
$result = mysql_query("SELECT FROM phphreak_users ORDER BY last_name");
$myrow = mysql_fetch_row($result);
}
else {
$result = mysql_query("SELECT * FROM phphreak_users ORDER BY username");
$myrow = mysql_fetch_row($result);
}
$count = mysql_query("SELECT COUNT(*) FROM phphreak_users");
printf("<u>User Management</u><br><br>\n");
if($countrow = mysql_fetch_array ($count)) {
echo "There are currently " . $countrow[0] . " registered users.<br><br>\n";
}
printf("Sort by <a href=\"$PHP_SELF?sort=username\">username</a>, <a href=\"$PHP_SELF?sort=firstname\">first name</a> or <a href=\"$PHP_SELF?sort=lastname\">last name</a>.<br><br>");
echo "
<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
<tr>
<td><b>Username:</b></td><td width=\"15\"></td><td><b>Name:</b></td><td width=\"15\"></td><td></td></tr>";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s</td><td></td><td>%s %s</td>", $myrow[4], $myrow[0], $myrow[1]);
printf("<td></td><td>(<a href=\"$PHP_SELF?edituser=%s\">edit</a>)\n", $myrow[4]);
}
} else {
printf("You do not have access to the admin website.");
}
include("../../includes/footer.inc");
?>