Hey everyone!
Having a few issues with a project im working on.
Im trying to get an error message to return when the site im working on returns a table with no results.
Its a CD sales website and the user can sort music by different categories. This works fine. However, if they select a category that has no CDs in it id like to return an error message rather than just a blank table...(removing the category from the list isnt an option.
Ive tried something like:
though im just getting errors back...if anyone can point me in the right direction i shall be very grateful!Code:<?php // Make an SQL query to show all categories $CategorySQL = "SELECT * FROM nmc_category ORDER BY catDesc"; // connect to the database include('*file URL*'); // execute the query $rsCategory = mysql_query($CategorySQL); echo "<form action=\"*FILE URL*\" method=\"get\"> \n"; echo "<select name= \"CategoryName\">\n"; echo "<option value=\"all\">Show All CDs</option>"; // loop through all the categories in the record set // while if (mysql_num_rows($rsCategory) < 1) { echo "no results found"; } else { $row = mysql_fetch_array ($rsCategory); $CategoryDesc = $row['catDesc']; $CategoryID= $row['catID']; echo "\t<option value = \"$CategoryDesc\">$CategoryDesc</option>\n"; } //Each record display as an option in a form // end loop echo "</select>\n"; echo "<br /><input type=\"submit\" value=\"See Category\" />"; echo "</form>" ?>






Bookmarks