php - Why is My Code not showing results -


can code. code asks 1 of 2 things. if postcode entered code radius search , searches database rows containing postcodes in array. if city / street entered want code bypass , search rows containing them details. code below.

    $postcode = str_replace( '+', '%20', $postcode );  $conn = mysql_connect('127.0.0.1','user','pass') or die('db connect error:'.mysql_error()); mysql_select_db('database', $conn) or die('could not select database');  $sqlstring = "select * postcodelatlng postcode ='".$postcode."'"; $result = mysql_query($sqlstring);     $row = mysql_fetch_assoc($result);  $lng = $row["longitude"] / 180 * m_pi; $lat = $row["latitude"] / 180 * m_pi;  mysql_free_result($result);      $sqlstring2 = "select distinct    postcodelatlng.postcode,   (     6367.41 * sqrt(       2 * (         1- cos(radians(postcodelatlng.latitude)) * cos(".$lat.") * (           sin(radians(postcodelatlng.longitude)) * sin(".$lng.") + cos(radians(postcodelatlng.longitude)) * cos(".$lng.")         ) - sin(radians(postcodelatlng.latitude)) * sin(".$lat.")       )     )   ) distance    postcodelatlng postcodelatlng  having distance <= '".$radius."' order distance ";  $result1 = mysql_query($sqlstring2) or die('query failed: ' . mysql_error());     while($row = mysql_fetch_array($result1)){         if ($row['postcode'] == 0){              $sqlstring3="select * property_details  street = '".$postcode."' or address3 = '".$postcode."' or county = '".$postcode."' ";     $result2 = mysql_query($sqlstring3) or die('query failed: ' . mysql_error());         while($row2 = mysql_fetch_array($result2)) {             echo '      <div class="container">         <div class="row">             <a href="viewprop.php?id='.$row2[0].'">                 <div class="col-md-12">                      <div class="col-md-12 col-md-offset-0 inner col-xs-12" align="justify">                         <div class="col-md-2 col-xs-12">                             <img src="images/rentals/1.jpg" width="80%" height="80%" />                         </div>                         <div class="col-md-8 col-xs-12">                             <h2>'. $row2[13]. '</h2>                         </div>                         <div class="col-md-2 col-xs-12">                             <h4 class="rbgclr2">£'. $row2[2]. ' per month</h3>                             <h5 class="rbgclr1">£'. $row2[3]. ' deposit</h4>                             <br />                             <p>bedrooms = '. $row2[4]. '</p>                         </div>                     </div>                 </div>             </a>         </div>     </div>             <br />';         }         }         else {             $sqlstring4="select * property_details postcode = '".$row['postcode']."' ";     $result3 = mysql_query($sqlstring4) or die('query failed: ' . mysql_error());         while($row2 = mysql_fetch_array($result3)) {             echo '      <div class="container">         <div class="row">             <a href="viewprop.php?id='.$row2[0].'">                 <div class="col-md-12">                      <div class="col-md-12 col-md-offset-0 inner col-xs-12" align="justify">                         <div class="col-md-2 col-xs-12">                             <img src="images/rentals/1.jpg" width="80%" height="80%" />                         </div>                         <div class="col-md-8 col-xs-12">                             <h2>'. $row2[13]. '</h2>                         </div>                         <div class="col-md-2 col-xs-12">                             <h4 class="rbgclr2">£'. $row2[2]. ' per month</h3>                             <h5 class="rbgclr1">£'. $row2[3]. ' deposit</h4>                             <br />                             <p>bedrooms = '. $row2[4]. '</p>                         </div>                     </div>                 </div>             </a>         </div>     </div>             <br />';         }     }     }     mysqli_close($con);   ?> 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -