Hi all,
I have set up a database/web interface where users can register for a course.
Firstly the code checks if the user(ffnumber) is already in the database.
If it is then a query is performed to check if the user is registered for this course.
If that user is already registered for that course then a message should be displayed informing the user of this and the code should stop here.(exit😉
However, if I am registering two users at once(select menu list) for the one course and one is already registered for the course then I am unable to register the other one.
Tried using if else but not working - if one person is already in the database registered for a different course then they will not be registered even though I want them to be.
Think problem is $num_results2;
else if((mssql_num_rows($check) == 0) || ($num_results2 == 0))
How do I work this out?
Any ideas? Hope this makes sense.
// CHECK IF FFNUMBER ALREADY IN DATABASE
$query = "SELECT class_ID ".
"FROM training ".
"WHERE ffnumber = '$ffnumber'";
$check = mssql_query($query) or die('Training Query Error');
$num_results = mssql_num_rows($check);
// CHECK IF FFNUMBER ALREADY REGISTERED FOR THIS CLASS
if(mssql_num_rows($check) > 0)
{
while($row= mssql_fetch_array($check))
{
$class = $row['class_ID']; // SET VARIABLE
// CHECK IF DATE/COURSE MATCH
$query2 = "SELECT * ".
"FROM class ".
"WHERE class_ID = '$class' ".
"AND course_ID = '$course'".
"AND class_start = '$class_start' ".
"AND class_end = '$class_end'";
$result2 = mssql_query($query2) or die('Select Query Error');
$num_results2 = mssql_num_rows($result2);
// IF ALREADY REGISTERED PRINT THIS...
if($num_results2 > 0)
{
echo '<p>'.$firstname.' already registered for this class.</p>';
echo '<ul> '.
'<li>Class Begins: '.$class_start.'</li> '.
'<li>Class Ends: '.$class_end.'</li></ul>';
echo '<p>Please go back and select a different date <br />'.
'<a href="index.php">Return</a></p>';
//exit;
}
} // end while
} // end if
else if((mssql_num_rows($check) == 0) || ($num_results2 == 0))
{
echo '<p>ROWS - RESULTS2'.$num_results2.'</p>';
$query = "...";
}