MySQL PHP
From KOP KB
<?
//connection information
$host = 'mysqlv108';
$user = 'chsalezip';
$pass = 'Ch54l351nC';
$db = 'chsalezip';
$conn = mysql_connect($host, $user, $pass);
//connection needs db name below
mysql_select_db("chsalezip", $conn);
$search = $_POST["tZip"];
// after the from is whatever table you are attempting to pull data from
$connstring = "SELECT * FROM distributors WHERE searchZip LIKE '$search' " ;
$result = mysql_query($connstring);
?>
<?
echo "<h1>Stores Near You:</h1>";
// after each bold is a column name so its appears organized
if(mysql_num_rows($result) == 0) {
echo "Sorry there appears to be no stores in your immediate area.";
}
else{
while($nt=mysql_fetch_array($result)){
echo "<br />";
echo "<br />";
// for each $nt has a correlated column name to display
// something else to display the content
echo "<h4>$nt[sName]</h4>$nt[sAdd]<br />$nt[sCity]<br />$nt[sZip], $nt[sState]<br />$nt[sPhone]";
}
echo "<br />";
echo "<br />";
}
echo mysql_error();
mysql_close();
?>