Help need it creating a search engines like those in Real Estate sites

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jguillen
    New Member
    • Feb 2007
    • 5

    Help need it creating a search engines like those in Real Estate sites

    I am new new in php, but I have been achieving some kind of good progress until I reached a problem....

    Create a search form that you can select differents options, radio buttons and so on.... I do not know how make the query correctly.... Please help. It is just like those search in Real Estate pages or airlines search.... Thx for your support
  • xwero
    New Member
    • Feb 2007
    • 99

    #2
    Originally posted by jguillen
    I am new new in php, but I have been achieving some kind of good progress until I reached a problem....

    Create a search form that you can select differents options, radio buttons and so on.... I do not know how make the query correctly.... Please help. It is just like those search in Real Estate pages or airlines search.... Thx for your support
    you have to build your query string controlling the input.

    [PHP]
    <?php
    if($_POST['search']){
    $mysql = 'SELECT id,title,text FROM searchtable ';
    $where = '';
    // catch posts for security checks (not worked out)
    $fire = $_POST['fire'];
    $ice = $_POST['ice'];
    // fire option processing
    if('' != $fire){ $where = 'fire=1'; }
    // ice option
    if(count($ice) > 0){ $where .= ' ice IN ('.implode(',', $ice).')'; }
    // add where variable to mysql string
    if('' != $where){ $mysql .= 'where '.$where; }
    // query processing
    }
    ?>
    <form>
    <p><input type="checkbox" name="fire" value="1"> Fire</p>
    <p><input type="checkbox" name="ice[]" value="1"> Ice water<br>
    <input type="checkbox" name="ice[]" value="2"> Ice cubes<br>
    <input type="checkbox" name="ice[]" value="3"> shredded ice<br></p>
    <p><input type="submit" name="search" value="Search"> </p>
    </form>
    [/PHP]
    The example doesn't make much sense but it's the build of the query sting that's important.

    Comment

    • jguillen
      New Member
      • Feb 2007
      • 5

      #3
      Thx, it is getting closer.

      Comment

      • jguillen
        New Member
        • Feb 2007
        • 5

        #4
        Here the form:

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <title>Untitl ed Document</title>
        </head>

        <body>
        <table width="300" border="0" cellpadding="0" cellspacing="0" >
        <tr>
        <th scope="col"><fo rm id="form1" name="form1" method="post" action="13.PHP" >
        <table cellspacing="0" cellpadding="0" >
        <tr>
        <td colspan="5"><di v> Buscar propiedad </div></td>
        </tr>
        <tr>
        <td colspan="5"><im g src="http://paradisso.com.d o/reg/do/img/1x1.gif" border="0" height="5" width="1" /></td>
        </tr>
        <tr>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="casa" checked="checke d" type="checkbox" /></td>
        <td align="left" width="50">casa </td>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Apartame nto" type="checkbox" /></td>
        <td align="left" width="50">Apar tamento</td>
        </tr>
        <tr>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="villas" checked="checke d" type="checkbox" /></td>
        <td align="left" width="50">Vill as</td>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="fincas" type="checkbox" /></td>
        <td align="left" width="50">Finc as</td>
        </tr>
        <tr>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Solares" type="checkbox" /></td>
        <td align="left" width="50">Sola res</td>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Locales Comerciales" type="checkbox" /></td>
        <td align="left" width="50">Loca les Comerciales</td>
        </tr>
        <tr>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Proyecto s Turisticos" type="checkbox" /></td>
        <td align="left" width="50">Proy ectos Turisticos</td>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Edificio s Completos" type="checkbox" /></td>
        <td align="left" width="50">Edif icios Completos</td>
        </tr>
        <tr>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Penthous e" type="checkbox" /></td>
        <td align="left" width="50">Pent house</td>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Oficinas " type="checkbox" /></td>
        <td align="left" width="50">Ofic inas</td>
        </tr>
        <tr>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Naves" type="checkbox" /></td>
        <td align="left" width="50">Nave s</td>
        <td width="10"><inp ut id="tipoinmuebl e" name="tipoinmue ble" value="Hoteles" type="checkbox" /></td>
        <td align="left" width="50">Hote les</td>
        </tr>
        <tr></tr>
        <tr>
        <td colspan="5"><im g src="http://paradisso.com.d o/reg/do/img/1x1.gif" border="0" height="10" width="1" /></td>
        </tr>
        <tr>
        <td colspan="5"><se lect name="localizac ion" id="localizacio n" onchange="updat eSectors(this); ">
        <option value="" selected="selec ted">- Provincias</option>
        <option value="11">Azua </option>
        <option value="14">Baho ruco</option>
        <option value="12">Bara hona</option>
        <option value="35">bbb</option>
        <option value="18">Daja bon</option>
        <option value="29">Duar te</option>
        <option value="32">El Seibo</option>
        <option value="17">Elia s Pi&ntilde;a</option>
        <option value="22">Espa illat</option>
        <option value="34">Gasp ar Hernandez</option>
        <option value="31">Hato Mayor</option>
        <option value="15">Inde pendencia</option>
        <option value="5">La Altagracia</option>
        <option value="4">La Romana</option>
        <option value="9">La Vega</option>
        <option value="30">Mari a Trinidad Sanchez</option>
        <option value="24">Mons e&ntilde;or Nouel</option>
        <option value="27">Mont e Plata</option>
        <option value="19">Mont ecristi</option>
        <option value="25">Ocoa </option>
        <option value="13">Pede rnales</option>
        <option value="7">Perav ia</option>
        <option value="1">Puert o Plata</option>
        <option value="23">Salc edo</option>
        <option value="8">Saman a</option>
        <option value="26">San Cristobal</option>
        <option value="16">San Juan</option>
        <option value="6">San Pedro De Macoris</option>
        <option value="28">Sanc hez Ramirez</option>
        <option value="10">Sant iago</option>
        <option value="20">Sant iago Rodriguez</option>
        <option value="3">Santo Domingo</option>
        <option value="21">Valv erde</option>
        <option value="guerrero ">guerrero</option>
        <option value="tineo">t ineo</option>
        </select>
        </td>
        </tr>
        <tr>
        <td colspan="5"><se lect name="img" size="1" id="img">
        <option value="azua">az ua</option>
        </select>
        </td>
        </tr>
        <tr>
        <td colspan="5"><se lect id="precio" name="precio" onchange="money Range('1');">
        <option value="0">RD$ 0</option>
        <option value="500000"> RD$ 500,000</option>
        <option value="1000000" >RD$ 1,000,000</option>
        <option value="1500000" >RD$ 1,500,000</option>
        <option value="2000000" >RD$ 2,000,000</option>
        <option value="3000000" >RD$ 3,000,000</option>
        <option value="5000000" >RD$ 5,000,000</option>
        <option value="7000000" >RD$ 7,000,000</option>
        <option value="10000000 ">RD$ 10,000,000</option>
        <option value="15000000 ">RD$ 15,000,000</option>
        <option value="25000000 ">RD$ 25,000,000</option>
        <option value="500">RD$ 500</option>
        </select>
        </td>
        </tr>
        <tr>
        <td colspan="5"><se lect id="pmax" name="pmax" onchange="money Range('1');">
        <option value="500000"> RD$ 500,000</option>
        <option value="1000000" >RD$ 1,000,000</option>
        <option value="1500000" >RD$ 1,500,000</option>
        <option value="2000000" >RD$ 2,000,000</option>
        <option value="3000000" >RD$ 3,000,000</option>
        <option value="5000000" >RD$ 5,000,000</option>
        <option value="7000000" >RD$ 7,000,000</option>
        <option value="10000000 ">RD$ 10,000,000</option>
        <option value="15000000 ">RD$ 15,000,000</option>
        <option value="25000000 ">RD$ 25,000,000</option>
        <option value="99999999 9">RD$ +50,000,000</option>
        </select>
        </td>
        </tr>
        <tr>
        <td colspan="5"><im g src="http://paradisso.com.d o/reg/do/img/1x1.gif" border="0" height="10" width="1" /></td>
        </tr>
        <tr>
        <td width="10"><inp ut type="checkbox" />
        </td>
        <td colspan="4" align="left"> Solo propiedades con foto </td>
        </tr>
        <tr>
        <td width="10"><inp ut id="newonly" name="newonly" value="1" type="checkbox" />
        </td>
        <td colspan="4" align="left"> Solo propiedades nuevas </td>
        </tr>
        <tr>
        <td width="10"><inp ut id="trademode" name="trademode " value="b" checked="checke d" onclick="toggle PriceRange('b') ;" type="radio" />
        </td>
        <td align="left" width="50"> Comprar </td>
        <td width="10"><inp ut id="trademode" name="trademode " value="r" onclick="toggle PriceRange('r') ;" type="radio" />
        </td>
        <td align="left"> Alquilar </td>
        <td></td>
        </tr>
        <tr>
        <td colspan="5"><im g src="http://paradisso.com.d o/reg/do/img/1x1.gif" border="0" height="8" width="1" /></td>
        </tr>
        <tr>
        <td colspan="5" align="left" valign="top">B& uacute;squeda por c&oacute;digo
        <input name="srch_byco de" id="srch_bycode " size="4" type="text" /></td>
        </tr>
        <tr>
        <td colspan="5"><la bel for="Submit"></label>
        <input type="submit" name="Submit2" value="buscar" id="Submit" /></td>
        </tr>
        </table>
        </form>
        </th>
        </tr>
        </table>
        </body>
        </html>

        Comment

        • jguillen
          New Member
          • Feb 2007
          • 5

          #5
          I want to search for some of those options or for all of them....


          PLEASE HELP!!!

          Comment

          • jguillen
            New Member
            • Feb 2007
            • 5

            #6
            THIS IS THE PHP code that searches for some of the options:

            <?php
            $dbh=mysql_conn ect ("localhost" , "xxxx", "xxxx") or die ('I cannot connect to the database because: ' . mysql_error());
            mysql_select_db ("amigos");
            // This could be supplied by a user, for example
            $tipoinmueble = $_POST['tipoinmueble'];
            $localizacion = $_POST['localizacion'];


            // Formulate Query
            // This is the best way to perform a SQL query
            // For more examples, see mysql_real_esca pe_string()
            $query = sprintf("SELECT * FROM friends WHERE tipoinmueble='$ tipoinmueble' and localizacion='$ localizacion'",
            $result = mysql_query($sq l,$conexio);

            echo "<TABLE BORDER='0'>";
            while ($row= mysql_fetch_arr ay($result))
            {

            echo"<tr>";
            echo "<td bgcolor=#EBEBEB >&nbsp;".$row['tipoinmueble']."</td>";
            echo"</tr>";
            echo"<tr>";
            echo "<td>".$row['localizacion']."</td>";
            echo"<tr>";
            }
            echo "</TABLE>";

            //echo "<td>".$row['negocio']."</td>";
            //echo "<td>".$row['direccion']."</td>";
            ?>


            Please somebody help me to make work, I have been coding it for weeks I am almost done on it.....

            Comment

            Working...