Jump to content

Search engine for suburbs


petonii

Recommended Posts

Hello fellow programmers,

 

I am new to this site and was looking around for some good advice or if i am lucky some help.

 

I am starting off a basic local business search project just for some practice.

 

I need some tutorial or some example code. I don't want to waste too much time for others so ill make this quick.

 

http://au.local.yahoo.com/ This link shows 2 search bars. I only want to know the postcode search side of things.

I wanna be able to write 90210 for example and then every business with the postcode 90210 comes up on a custom page.

How do you label each business with a postcode and make it up on a section of my website?

 

I hope this is clear. If any fingers can be pointed to a very clear source that would be great. I understand some coding but not advanced enough to write it from scratch.

 

Thanks in advanced

 

Peace >.<

Link to comment
https://forums.phpfreaks.com/topic/59153-search-engine-for-suburbs/
Share on other sites

each business needs to have their postal code in your databse, then you do an SQL search:

 

<?php
if(is_numeric($_POST['postCode'])){
   $postCode = $_POST['postCode'];
   $sql = mysql_query("SELECT * from `dataBaseName` WHERE `postCode` = '$postCode'")or die(mysql_error());
   if(mysql_num_rows($sql) < 1){
      echo 'Nothing found.';
   }else{
      while($row = mysql_fetch_array($sql)){
         echo '<p>'.$row['businessName'].'</p>';
      }
   }
}else{
   echo 'Please enter a number';
}
?>

 

Does this answer your question or was I off?

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.