Hi...
I'm in a fix... I'm attempting to run a query on a table in my database, and if the query doesn't find anything, I want a certain $display variable to echo.
However... what's happening is that, if the query doesn't find anything in the table, it doesn't display the $display variable at all.
An example of my code is below:
$find_mission = "SELECT MAX(mission_no) FROM mission";
$find_mission_result = @mysql_query($find_mission, $connect) or die(mysql_error());
while ($row = mysql_fetch_array($find_mission_result)) {
$mission = $row['MAX(mission_no)'];
}
// Other variables listed below are defined here //
$mis_details_360th = "SELECT * FROM mission WHERE mission_no = '$mission' AND plane_squadron = '360th' ORDER BY plane_name ASC";
$mis_details_360th_result = @mysql_query($mis_details_360th, $connect) or die(mysql_error());
$num_360th_check = mysql_num_rows($mis_details_360th_result);
if($num_360th_check == "0") {
$display_360th_totals = "
<tr>
<td width=20% bgcolor=#ffffff></td>
<td width=10% bgcolor=#ffffff></td>
<td width=10% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=22% bgcolor=#ffffff></td>
</tr>
<tr>
<td width=100% colspan=10 align=center bgcolor=#EFEFEF><font face=\"Century Gothic\" size=1 color=red><b>360th Squadron on Stand Down for Mission $mission.</b></font></td>
</tr>";
} else {
$display_360th_totals = "
<tr>
<td width=20% bgcolor=#ffffff></td>
<td width=10% bgcolor=#ffffff></td>
<td width=10% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=6% bgcolor=#ffffff></td>
<td width=22% bgcolor=#ffffff></td>
</tr>
<tr>
<td width=20% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>360th Totals</b></center></font></td>
<td width=10% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center> </center></font></td>
<td width=10% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>$tot_360th_perc_rnd%</b></center></font></td>
<td width=6% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>$kill_tot_360th</b></center></font></td>
<td width=6% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>$dmg_tot_360th</b></center></font></td>
<td width=6% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>$kia_360th_tot_count</b></center></font></td>
<td width=6% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>$wia_360th_tot_count</b></center></font></td>
<td width=8% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>$sh_360th_tot_count</b></center></font></td>
<td width=6% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center><b>$pow_360th_tot_count</b></center></font></td>
<td width=22% bgcolor=#EFEFEF><font size=1><font face=\"Century Gothic\" color=#800000><center> </center></font></td>
</tr>";
}
I want the "$display_360th_totals" to either show the results queried from the database, or, if the query doesn't find anything, to display the "360th Squadron on Stand Down" variable.
I created the mysql_num_rows variable ("$num_360th_check") for the express purpose to do this... I've error checked that variable to ensure that it's getting the results I'm looking for.
I'm not sure what I'm doing wrong. Anyone have any ideas?