hi, i am trying to select recordset from mysql based on parameter passed from html (vzip is view)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>ZIP Code</title>
</head>
<body>
<form action="zip.php" method="post">
ZIP Code: <input type="text" name="zip">
<p><input type="Submit">
<br>
<br>
</p>
</form>
</body>
</html>
zip.php
<?php
$username="root";
$password="jp";
$database="db2";
$zip=$_POST['zip'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT * FROM vzip WHERE zip='$zip' ";
mysql_query($query);
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$zip=mysql_result($result,$i,"zip");
$state=mysql_result($result,$i,"state");
$city=mysql_result($result,$i,"city");
$county=mysql_result($result,$i,"ziplist_county");
$snowload=mysql_result($result,$i,"s");
echo "<br>ZIP: $zip<br>State: $state<br>City: $city<br>County: $county<br>Snow load: $snowload<br><hr><br>";
$i++;
}
?>
but instead of expected result
ZIP CITY STATE ZIPLIST_COUNTY S
54501 Rhinelander WI Oneida 60
i am getting:
Database Output
"; $zip=mysql_result($result,"zip"); $state=mysql_result($result,"state"); $city=mysql_result($result,"city"); $county=mysql_result($result,"ziplist_county"); $snowload=mysql_result($result,"s"); echo "
ZIP: $zip
State: $state
City: $city
County: $county
Snow load: $snowload
"; ?>
can anyone help me, please? this is my first project with php/mysql.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>ZIP Code</title>
</head>
<body>
<form action="zip.php" method="post">
ZIP Code: <input type="text" name="zip">
<p><input type="Submit">
<br>
<br>
</p>
</form>
</body>
</html>
zip.php
<?php
$username="root";
$password="jp";
$database="db2";
$zip=$_POST['zip'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT * FROM vzip WHERE zip='$zip' ";
mysql_query($query);
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$zip=mysql_result($result,$i,"zip");
$state=mysql_result($result,$i,"state");
$city=mysql_result($result,$i,"city");
$county=mysql_result($result,$i,"ziplist_county");
$snowload=mysql_result($result,$i,"s");
echo "<br>ZIP: $zip<br>State: $state<br>City: $city<br>County: $county<br>Snow load: $snowload<br><hr><br>";
$i++;
}
?>
but instead of expected result
ZIP CITY STATE ZIPLIST_COUNTY S
54501 Rhinelander WI Oneida 60
i am getting:
Database Output
"; $zip=mysql_result($result,"zip"); $state=mysql_result($result,"state"); $city=mysql_result($result,"city"); $county=mysql_result($result,"ziplist_county"); $snowload=mysql_result($result,"s"); echo "
ZIP: $zip
State: $state
City: $city
County: $county
Snow load: $snowload
"; ?>
can anyone help me, please? this is my first project with php/mysql.