Hello,
I have two databases. The first is a list of users. I want to pull each user from the first database and see if that user matches certain criteria in a second database. If they do not match then I want to output them to the screen and go on to the next user, if they do match then I want to output nothing to the screen and go on to the next user. Below is the method I tried to use, but it just displays nothing. Does anyone have a better method to use?
<?
//Pull list of students to compare to ClassHistory database
include 'db-login.php';
$list_get=mysql_query("SELECT * FROM Users")or die(mysql_error());
while($row3=mysql_fetch_array($list_get)){
$userid=$row3['UserID'];
include 'db-customers.php';
$enrolled2=mysql_query("SELECT * FROM 15517ClassHistory WHERE Completed='No' AND UserID='$userid'") or die(mysql_error());
while($row2=mysql_fetch_array($enrolled2)){
$studentid = $row2['UserID'];
if($studentid==""){
include 'db-login.php';
$student_get=mysql_query("SELECT * FROM Users WHERE UserID='$userid' ORDER BY LastName asc");
while($row=mysql_fetch_array($student_get)){
$fname=$row['FirstName'];
$lname=$row['LastName'];
$name = $lname . ", " . $fname;
include 'db-customers.php';
$enrolled=mysql_query("SELECT * FROM 15517ClassHistory WHERE UserID='$userid' AND Completed='No'") or die(mysql_error());
$numenrolled=mysql_num_rows($enrolled);
$completed=mysql_query("SELECT * FROM 15517ClassHistory WHERE UserID='$userid' AND Completed='Yes'") or die(mysql_error());
$numcompleted=mysql_num_rows($completed);
?>
<tr>
<td align=left><? echo $name; ?></td>
<td><? echo $numenrolled; ?></td>
<td><? echo $numcompleted; ?></td>
</tr>
<?
} } } }
?>
Thanks,
Johnie Karr