ok well ive done a script that basically echos all of the tables within my database into a combo box, the problem now is i want to validate it so if the user doesn't select a table then i want to echo that there wasn't no selection. i have made sure that i created a blank item within the select box aswel. here is my code. <?php $dbname = 'obso006_itemstock'; $sql = "SHOW TABLES FROM $dbname"; $result = mysql_query($sql); if (!$result) { echo "DB Error, could not list tables\n"; echo 'MySQL Error: ' . mysql_error(); exit; } echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] ."\">"; echo "<span class=\"style\">Please Select a Category:</span> <select name=\"dbtables\" id=\"dbtables\">\n"; echo "<option value=\"\"></option>"; while ($row = mysql_fetch_row($result)) { echo "<option value=\"".$row[0]."\">".$row[0]."</option>\n"; } echo "<input type=\"submit\" name=\"select_table\" value=\"Submit\"></select></form>"; mysql_free_result($result); ?> Code (markup):
$accept = array(); while ($row = mysql_fetch_row($result)) { echo "<option value=\"".$row[0]."\">".$row[0]."</option>\n"; $accept[$row[0]] = true; } if(!isset($accept[$_POST['dbtables']])) { ... } else { ... } PHP: Faster than in_array.