I am facing problem with search module for real estate property search .

m placing my code .. i am new 4 php... please help me with the correction of code...

// index.html

<form action="refinesearch.php" method="post">

                    <td>


                        <td><tr>
                        <label>

                            <span class="h"><b>Category:</b></span>&nbsp;</label>
                            </tr><select id="first" name="first" size="1" style='width:127px;'><option value="">--</option></select>
                    </td>               
                    <tr><td>
                        <select style="width:175px" >

                        <option value="Apartments">Apartments</option>
                        <option value="Independent Houses">Independent Houses</option>
                        <option value="Villas">Villas</option>
                        <option value="Plots">Plots</option><option value="6">Form House</option>
                        <option value="Other Residential Property">Other Residential Property</option></select></td>
                    </tr>
                   <tr><td>
                        <select id="second" name="second" size="1" style='width:175px;'>
                        <option value="">--</option></select>
                    </td></tr>

                 <tr><td> <select name='city' class='textcontrol' style='width:175px;float:left;' id='city'>
      <option value="Ahmedabad" >Ahmedabad(ALL)</option>


      <option value="Bangalore" >Bangalore(ALL)</option>


       <option value="Chennai" >Chennai(ALL)</option>


       <option value="Chandigarh" >Chandigarh(ALL)</option>


       <option value="Delhi/Noida">Delhi/Noida(ALL)</option>



       <option value="Hyderabad/Secunderabad" >Hyderabad/Secunderabad(ALL)</option>


       <option value="Indore" >Indore(ALL)</option>


       <option value="Kolkata" >Kolkata(ALL)</option>


       <option value="Mumbai" >Mumbai(ALL)</option>


      <option value="Pune" >Pune(ALL)</option>

    </select></td>
  </tr>
                        <t/r></td>
                        <tr><td>
                          <p>
                           <select name="bedrooms">
                              <option value="bed1"> 1 Bedroom</option>
                              <option value="bed2"> 2 Bedroom</option>
                              <option value="bed3"> 3 Bedroom</option>
                              <option value="bed4"> 4 Bedroom</option>
                              <option value="bed5"> 5 Bedroom</option>
                                    <option value="bed6">6 Bedroom</option>

                            </select>

                            <input type="submit" name="search" id="search" value="search" style="width:50px" />
                          </p></td>
                    </tr>

            </form>
            </tr>
</table>
<script type="text/JavaScript">
 $(document).ready(function()
 {
        var selectoptions = {
            "Buy": {
                 "key" : 50,
                 "defaultvalue" : 2000000,
                 "values" : {
                     "10 to 20 Lacs":1000000,
                     "20 to 40 Lacs": 2000000,
                     "40 to 50 Lacs": 4000000,
                     "50 to 80 Lacs": 8000000,
                     "80 to 1 Crore": 10000000,
                     "1 to 2 Crore": 20000000,
                     "2 to 3 Crore": 30000000,
                     "3 to 5 Crore": 50000000,
                     "5 to 10 Crore": 100000000,
                     "10 to 15 Crore": 150000000,
                     "15 to 20 Crore": 200000000,
                     ">20 Crore": 200000000
                     }
              },
              "Rent / Lease": {
                 "key" : 40,
                 "defaultvalue" : 15000,
                 "values" : {
                     "5000 to 10000":5000,
                     "10000 to 15000":10000,
                     "15000 to 20000":15000,
                     "20000 to 40000":20000,
                     "40000 to 70000":40000,
                     "70000 to 1 Lac":70000,
                     "1 to 2 Lacs":100000,
                     "2 to 5 Lacs":200000,
                      "5 to 10 Lacs":500000,
                      ">10 Lacs":1000000

                     }
              },
            "PG": {
                 "key" : 30,
                 "defaultvalue" : 2,
                 "values" : {
                     "4000 to 6000":4000,
                     "6000 to 8000":6000,
                     "8000 to 10000":8000,
                     "10000 to 15000":10000,
                     "15000 to 20000":15000,
                     "20000 to 30000":20000,
                     ">30000":30000

                     }
              }
    };

        $('#first').doubleSelect('second', selectoptions);     
 });
        </script></div>


     <div class="TabbedPanelsContent"> <table width="220" height="135"><tr>
            <form action="refinesearch.php" method="post">

                    <td>


                        <td><tr>
                        <label><span class="h"><b>Category:</b></span>&nbsp;</label> </tr><select id="third" name="third" size="1" style='width:127px;'><option value="">--</option></select>
                    </td>               
                    <tr><td>
                        <select style="width:175px" >

                        <option value="Office">Office</option>
                        <option value="Shop">Shop</option>
                        <option value="Land">Land</option>
                        <option value="Show Room">Show Room</option>
                        <option value="Business Centre">Business Centre</option>
                        <option value="Other Commercial Property">Other Commercial Property</option>
                        </select></td>
                    </tr>
                   <tr><td>
                        <select id="fourth" name="fourth" size="1" style='width:175px;'><option value="">--</option></select>
                    </td></tr>

                 <tr><td> <select name='city' class='textcontrol' style='width:175px;float:left;' id='city'>

      <option value="Ahmedabad" >Ahmedabad(ALL)</option>


      <option value="Bangalore" >Bangalore(ALL)</option>


       <option value="Chennai" >Chennai(ALL)</option>


       <option value="Chandigarh" >Chandigarh(ALL)</option>


       <option value="Delhi/Noida">Delhi/Noida(ALL)</option>



       <option value="Hyderabad/Secunderabad" >Hyderabad/Secunderabad(ALL)</option>


       <option value="Indore" >Indore(ALL)</option>


       <option value="Kolkata" >Kolkata(ALL)</option>


       <option value="Mumbai" >Mumbai(ALL)</option>


      <option value="Pune" >Pune(ALL)</option>

    </select></td>
  </tr>
                        <t/r></td>
                        <tr><td>
                          <p>
                           <select name="bedrooms">
                              <option value="bed1"> 1 Bedroom</option>
                              <option value="bed2"> 2 Bedroom</option>
                              <option value="bed3"> 3 Bedroom</option>
                              <option value="bed4"> 4 Bedroom</option>
                              <option value="bed5"> 5 Bedroom</option>
                                    <option value="bed6">6 Bedroom</option>

                            </select>


                            <input type="submit" name="search" id="search" value="search" style="width:50px" />
                          </p></td>
                    </tr>

            </form>
            </tr>
</table>
<script type="text/JavaScript">
 $(document).ready(function()
 {
        var selectoptions = {
            "Buy": {
                 "key" : 50,
                 "defaultvalue" : 2000000,
                 "values" : {
                     "10 to 20 Lacs":1000000,
                     "20 to 40 Lacs": 2000000,
                     "40 to 50 Lacs": 4000000,
                     "50 to 80 Lacs": 8000000,
                     "80 to 1 Crore": 10000000,
                     "1 to 2 Crore": 20000000,
                     "2 to 3 Crore": 30000000,
                     "3 to 5 Crore": 50000000,
                     "5 to 10 Crore": 100000000,
                     "10 to 15 Crore": 150000000,
                     "15 to 20 Crore": 200000000,
                     ">20 Crore": 200000000
                     }
              },
              "Rent / Lease": {
                 "key" : 40,
                 "defaultvalue" : 15000,
                 "values" : {
                     "5000 to 10000":5000,
                     "10000 to 15000":10000,
                     "15000 to 20000":15000,
                     "20000 to 40000":20000,
                     "40000 to 70000":40000,
                     "70000 to 1 Lac":70000,
                     "1 to 2 Lacs":100000,
                     "2 to 5 Lacs":200000,
                      "5 to 10 Lacs":500000,
                      ">10 Lacs":1000000

                     }
              }
    };

        $('#third').doubleSelect('fourth', selectoptions);     
 });
        </script></div>
   </div>
 </div>

 <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="js/jquery.doubleSelect.js"></script>


    </head>
    <body>





//refinesearch.php

<?php

//Create an empty variable
//$search_result = '';

//If statement, to check if the submit button has been clicked.
//if (isset($_POST['submit'])) {

//Connect To Database

$con=mysql_connect("localhost:3306","mymakaan_user","ramsinfo");

 mysql_select_db("mymakaan");


$category = $_POST['category']; //this is an string
$propertytype = $_POST['propertytype']; //this is a string
$price = $_POST['price'];
$city = $_POST['city'];
//$bedrooms = $_POST['bedrooms'];


//$sql="SELECT * from post WHERE  category='".$_POST['category']."' AND propertytype='".$_POST['propertytype']."'  AND city='".$_POST['city']."'";

$sql = "SELECT * FROM post WHERE category LIKE '%$category%' and propertytype LIKE '%$propertytype%' and  price LIKE '%$price%' and  city LIKE '%$city%' ";
//print("$sql");


//execute SQL query and get result
$sql_result = mysql_query($sql,$con) or die(mysql_error());
//print("after sql");

// Loop through the data set and extract each row into it's own variable set
/* while($row = mysql_fetch_array($sql_result))
     echo "6543";
   print("$row");
     var_dump($row);
      {
    extract($row) or die(mysql_error()) ;
         }*/

   while($row=mysql_fetch_object($sql_result))
       echo "6543";
       print("$row");

       var_dump($row);
{
echo "<div style='margin:0.5px; width:500px; height:300px; align:center; cellspacing:0; border:double; background:silver;'>{$row['postpropertyname']}  <br>".
      "Price : {$row['price']}<br>".
      "Area : {$row['area']}<br>".
      "Locality : {$row['locality']}<br>".
      "Bedrooms : {$row['bedrooms']}<br>".
       "Bathrooms : {$row['bathrooms']}<br>".

       "Locality : {$row['locality']}<br>". 
       "Amenities : {$row['amenities']}<br>".
        "Description : {$row['description']}<br>".
        "Contact Agent : {$row['contactname']}<br>".
        "Contact No.  : {$row['contactnumber']}<br><br>";

 echo "<a href='tryhyp123.php?postid={$row['postid']}'> "   . $category . " " . $propertytype ." " . $city ."<h5> See More </h6></a></div> ";


}

?>
Thanks in advance

Recommended Answers

All 7 Replies

what is the problem u face
error, no result, invalid result or any other
tell specific problem

Thanks for ur response...

Its showing no result...
showing bool(false) when var_dump($row)

uncomment //print $sql; in line 305
copy that prepared query from browser and run in phpmyadmin, see the result or sql error there

thanks...
i checked for dt $sql query ..
wen i run that on phpmyadmin..
its showin no results return...

so try with some search word that return result

i have tried word search.. its workin well.. i am facing problem with multiple values in dropdown boxes...

again u did not saying whats the problem, facing problem means what?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.