I am trying to get the following code to display 'No documents found' message if nothing exists based on the query. Everything works properly when data is found, but if it is empty it seems not to return anything. I have tried: if(isset($WP_title)) and even if(empty($WP_title)) without any luck. Could someone please take a look at the code and see what I am doing wrong? Thank You.
$sqlWP = "SELECT * FROM file_library WHERE file_type = \"WhitePaper\" AND (part_numbers like '%$model_number%' OR part_numbers = 'all') ORDER BY file_title ASC";
$sqlWP_result = mysql_query($sqlWP,$connection) or die("Couldn't connect to database");
while ($rowWP = mysql_fetch_array($sqlWP_result)) {
$WP_title = $rowWP['file_title'];
$WP_file_id = $rowWP['file_library_id'];
$WP_filenam = $rowWP['filenam'];
if(isset($WP_title)) {
$print_WP .= " <a href=\"http://www.domainname.com/path_to_file/$WP_filenam\"> <font size=\"-1\" face=\"arial\" color=\"red\"> $WP_title <BR> </font> </a>";
} else {$print_WP .= " <font size=\"-1\" face=\"arial\" color=\"black\"> No documents found <BR> </font> </a>";}
}