I've created an html form using php that displays a single row from a database table based on a variable value from a form. In this case entering a zip code that displays the city. I went to myphpadmin and did a search on the zip code and pull the name from the the ZIP5, Latitude, Longitude, Name, State, County, Statenum Stateabbrev, Statename. Just to give an idea, I used the a search on myphpadmin. Here is the query on zip codes
SELECT * FROM ZIP5 WHERE ZIP5 LIKE '01561'. Although, it's not returning any data from the db when I enter my zip. What else I'm missing?
<?php
require_once('con/condb.php');
if (ctype_digit($zip) && (preg_match('/\d{5}/', $zip))){
echo $zip, ' is a valid zip code.';
}
$sql = "SELECT * FROM `ZIP5` WHERE `Name`";
$result = mysql_query($sql) or die ("Could not perform the query");
print ("We got" . mysql_num_rows($result) . "rows in our result<br/>");
print"<table border=0>";
while ($row = mysql_fetch_assoc($result)) {
print "<tr><td>" .$row["City"] ."</td></tr>";
}
print "</table>";
$zip = "";
if (isset($_POST['Submit'])) {
$zip = $_POST['zip'];
if (is_numeric($zip)){
} else {
echo "<p>Enter a zip code.</p>\n";
}
echo "<p>Your zip is, " .$zip. "</p>\n";
}
?>
<form name "Zip Code" action="testdemo.php" method="post">
<p>Enter your Zip Code <input type="text" name="zip" value="<?php echo $zip; ?> "/></p>
<input type="submit" name="Submit" value="Send Form"/>
</form>