Jump to content

[SOLVED] exact matches


netpants

Recommended Posts

This is what I have, I am trying to do a query from a form. In my select from part of the code, what do i need to change in there so that it looks for the City to be exactly what is entered, the County is exactly what is entered and the street can come up with anything similar. I would appreciate your help 

 

 

// connect and select the database 
   $conn = mysql_connect($host, $user, $password) or die(mysql_error()); 
   $db = mysql_select_db($dbName, $conn) or die(mysql_error()); 
$county = $_POST['county'];
$city = $_POST['city'];
$street = $_POST['street'];
$zip= $_POST['zip'];
$cp = $_POST['cp'];


// Insert a row of information into the table "example"
$result = mysql_query("SELECT * FROM coords WHERE street LIKE '$street%'") 
or die(mysql_error());   

echo "<table border='0'>";
echo "<tr> <th>County</th><th>City</th><th>Address</th><th></th><th></th><th></th><th>Coordinates</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table 
echo "<tr><td>"; 
echo $row['county'];
echo "</td><td>"; 
echo $row['city'];
                echo "</td><td>"; 
echo $row['number'];
echo "</td><td>";
                echo $row['cp'];
echo "</td><td>";
                echo $row['street'];
echo "</td><td>";
                echo $row['sfx'];
echo "</td><td>";
                echo $row['coordinates'];
echo "</td></tr>";  
}
?>

Link to comment
https://forums.phpfreaks.com/topic/75528-solved-exact-matches/
Share on other sites

Ok I have a form its layed out like this.

 

County:        City:            Street:            Zip:

 

People are going to enter in information in this form and get results from my database. When they type in county, city,street, and zip it will look in my database and bring up whatever matches exactly what they typed in. There is a column for eatch of those fields in my table i call coords. So if they type County: Happy  City: Unhappy City  Street: Boringsville  Zip: 65050  , it would take that information and look for an exact match in my database and display it.

Link to comment
https://forums.phpfreaks.com/topic/75528-solved-exact-matches/#findComment-382194
Share on other sites

this is what I did and it seemed to work, i just wont get similar stuff to whatever is entered in the street name filed.

 

$result = mysql_query("SELECT * FROM coords WHERE street='$street' AND city='$city' AND county='$county' AND sfx='$sfx'") 
or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/75528-solved-exact-matches/#findComment-382258
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.