Hi all.
I'm having trouble with an if else statement in my code that I can't figure out.
Here's my code:
<?php
$db_name = "database";
$connect = @mysql_connect("localhost", "username", "password") or die(mysql_error());
$db = @mysql_select_db($db_name, $connect) or die(mysql_error());
$nhire = "SELECT pilot_id, pilot_fname, pilot_lname, pilot_email, pilot_hub, pilot_enlistment FROM pilot WHERE pilot_code = '0' AND pilot_rank = '0' AND pilot_security = '0' ORDER BY pilot_enlistment";
$nhire_result = @mysql_query($nhire, $connect) or die(mysql_error());
$check = mysql_num_rows($nhire_result);
$i = "0";
while ($row = mysql_fetch_array($nhire_result)) {
$p_id = $row['pilot_id'];
$p_fname = $row['pilot_fname'];
$p_lname = $row['pilot_lname'];
$p_email = $row['pilot_email'];
$p_hub = $row['pilot_hub'];
$p_hire = $row['pilot_enlistment'];
$p_emaillink = "<a href=mailto:$p_email>$p_email</a>";
$app_date = date('M d Y', $p_hire);
if ($i % 2) {
$bgcolor = "#FFFFFF";
} else {
$bgcolor = "#F1F1F1";
}
if($check != "0") {
$display_result = "This is if NUM CHECK does NOT equal zero.";
} else {
$display_result = "This is if the NUM CHECK DOES equal zero.";
}
$i++;
}
?>
<html>
<head>
<title>New Page 2</title>
</head>
<body>
<?php echo "$display_result"; ?>
</body>
</html>
If the variable $check is greater than zero, then everything works fine. However... if $check equals zero (i.e., there are no records found in the query), then the "This is if the num check does equal zero" never shows up. I get a blank page.
I've been messing with this for a couple days now and just can't figure out where the problem is.
Any help would be greatly appreciated.