I still cant seem to get this to work right.
If there is only 1 result, i wanted it to redirect to the redirecturl, in my datbase, if there are no reults, then diplay "NO RESULTS"
and if there are more then 1 result, loop through and display them out.
PHP Code:<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
require_once ('connect.php');
require_once ('opendb.php');
$zipcode = $_POST['zipcode_entered_search'];
$query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode'";
$result = @mysql_query ($query);
$count = mysql_num_rows($result); //number of results
if ($count == 0){
echo "No localtions are found";
}else if($count == 1){
//redirect
}else if($count > 1){
echo "<b>Located $count result(s)</b><br />";
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo $row['company_name'] . '<br>' .'<a href="'. $row['redirect_url'] . '"> Visit Website </a>'. ' ' .'<br>' . $row['notes_1'] . '<p>';
}
}
}
}else{
// nothing
}
?>




Reply With Quote