A Little Help Please
Posted: Wed Feb 18, 2009 7:53 am
I know I'll probably get flamed, but I would like to hash out my problems trying to get the results I'm looking for. I have gone through a few different tutorials, but I may not have found the right one yet. I have posted my code below in hopes a PHP/MYSQL expert can push me in the right direction. I'll need to tweak my select statement as well. What I'm trying to do is have a user enter their zip code and have it return a facility based on the zip. It would be ideal to do some sort of radius search, but that will be my next step. Currently, I'm trying to return the lab state,city,address, and phone number. How would I display ALL of the results that are given for a particular zip code?
Thank you,
Joe
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
</body>
</html>
Thank you,
Joe
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
Code: Select all
<?php
$username="admin";
$password="pass";
$database="read";
$zipcode = $_GET["zip"];
$state = $_GET["state"];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT state,address,city,phone,days,zip FROM labs WHERE zip = '$zipcode'";
//$db_connection = new mysqli("localhost", "admin", "pass", "read");
//$statement = $db_connection->prepare("SELECT zip FROM labs WHERE zip = ?");
//$statement->bind_param("s", $zipcode);
//$statement->execute();
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$rs=mysql_result($result,$i,"zip");
echo "<b>$rs
$field2-name2</b><br>$field3-name<br>$field4-name<br>$field5-name<hr><br>";
$i++;
}
?>
</html>