php - Multiple Address from a database in Google Maps API -


i have bunch of addresses in database , trying figure out how put multiple addresses in map. addresses dependent on user searches such city or number of bedrooms changes depending on search. far have manage have 1 address on map. way can combine 2 show addresses searched along points on map or modify code have?

here google maps api code

            var geocoder;             var map;             function initialize() {               geocoder = new google.maps.geocoder();               var latlng = new google.maps.latlng(49.2505, -123.1119);               var mapoptions = {                 zoom: 15,                 center: latlng,                 maptypeid: google.maps.maptypeid.roadmap               }               map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions);             }              function codeaddress() {               var address = '<?php echo json_encode($varstreetaddress);?> <?php echo json_encode($varcity);?>, bc';               geocoder.geocode( { 'address': address}, function(results, status) {                 if (status == google.maps.geocoderstatus.ok) {                   map.setcenter(results[0].geometry.location);                   var marker = new google.maps.marker({                       map: map,                       position: results[0].geometry.location                   });                 } else {                   alert('geocode not successful following reason: ' + status);                 }               });             }              google.maps.event.adddomlistener(window, 'load', initialize); 

here code searching database

<?php     $mysqli = new mysqli("localhost","root","", "");         if ($mysqli->connect_errno) {             echo "failed connect mysql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;         } ///////////set search variables $property = $_post['property']; $bedroom = $_post['bedroomnumber']; $bathroom = $_post['bathroomnumber']; $pricemin = $_post['pricemin']; $pricemax = $_post['pricemax']; $termlease = $_post['termlease']; //////////search if(isset($_post['utilities']) && is_array($_post['utilities'])) {     foreach($_post['utilities'] $check) {              //echoes value set in html form each checked checkbox.                          //so, if check 1, 3, , 5 echo value 1, value 3, value 5.                          //in case, echo whatever $row['report id'] equivalent to.     } }   $sql = $mysqli->query("select * propertyinfo property '%$property%' , numbed '%$bedroom%' , numbath '%$bathroom%' , price >= '$pricemin' , price <= '$pricemax' , utilities '%$check%' , termlease '%$termlease%'");   if($sql === false) {     die(mysql_error()); // todo: better error handling  }  if($sql->num_rows){     while ($row = $sql->fetch_array(mysqli_assoc)){         echo '<div id="listing">                     <div id="propertyimage">                          <img src="uploadimages/'.$row['imagename1'].'" width="200" height="150" alt=""/>                      </div>                      <div id="basicinfo">                     <h2>$'.$row['price'].'</h2>                     <p style="font-size: 18px;"># '.$row['streetaddress'].', '.$row['city'].', bc</p>                     <p>'.$row['numbed'].' bedrooms | '.$row['numbath'].' bathrooms | '.$row['property'].'</p>                     <br>                     <p><a href="output2.php?record_id='.$row['id'].'" class="link2" target="_blank">view full details</a> | <a href="" class="link2">get directions</a>                      </div>                 </div>';      } } else { echo '<h2>0 search results</h2>'; }?> 

it nice see important part of html. dynamic page user add listings in database?

the problem found (in similiar project have) when use "and", seems user needs check boxes (or select options, etc). nothing can left alone, otherwise creates false search. results query, may not right result. have discovered people use jquery, collecting boxes - checked, , comparing database. user may check boxes, of time, boxes left unchecked, , means in category good, not none. instance, don't check 2 or 3 or 4 baths. means properties far bath concerned.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -