By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

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

P: 5
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
Feb 25 '07 #1
Share this Question
Share on Google+
5 Replies


P: 99
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.
Feb 25 '07 #2

P: 5
Thx, it is getting closer.
Feb 25 '07 #3

P: 5
Here the form:

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

<body>
<table width="300" border="0" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><form id="form1" name="form1" method="post" action="13.PHP">
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="5"><div> Buscar propiedad </div></td>
</tr>
<tr>
<td colspan="5"><img src="http://paradisso.com.do/reg/do/img/1x1.gif" border="0" height="5" width="1" /></td>
</tr>
<tr>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="casa" checked="checked" type="checkbox" /></td>
<td align="left" width="50">casa</td>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Apartamento" type="checkbox" /></td>
<td align="left" width="50">Apartamento</td>
</tr>
<tr>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="villas" checked="checked" type="checkbox" /></td>
<td align="left" width="50">Villas</td>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="fincas" type="checkbox" /></td>
<td align="left" width="50">Fincas</td>
</tr>
<tr>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Solares" type="checkbox" /></td>
<td align="left" width="50">Solares</td>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Locales Comerciales" type="checkbox" /></td>
<td align="left" width="50">Locales Comerciales</td>
</tr>
<tr>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Proyectos Turisticos" type="checkbox" /></td>
<td align="left" width="50">Proyectos Turisticos</td>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Edificios Completos" type="checkbox" /></td>
<td align="left" width="50">Edificios Completos</td>
</tr>
<tr>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Penthouse" type="checkbox" /></td>
<td align="left" width="50">Penthouse</td>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Oficinas" type="checkbox" /></td>
<td align="left" width="50">Oficinas</td>
</tr>
<tr>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Naves" type="checkbox" /></td>
<td align="left" width="50">Naves</td>
<td width="10"><input id="tipoinmueble" name="tipoinmueble" value="Hoteles" type="checkbox" /></td>
<td align="left" width="50">Hoteles</td>
</tr>
<tr></tr>
<tr>
<td colspan="5"><img src="http://paradisso.com.do/reg/do/img/1x1.gif" border="0" height="10" width="1" /></td>
</tr>
<tr>
<td colspan="5"><select name="localizacion" id="localizacion" onchange="updateSectors(this);">
<option value="" selected="selected">- Provincias</option>
<option value="11">Azua</option>
<option value="14">Bahoruco</option>
<option value="12">Barahona</option>
<option value="35">bbb</option>
<option value="18">Dajabon</option>
<option value="29">Duarte</option>
<option value="32">El Seibo</option>
<option value="17">Elias Pi&ntilde;a</option>
<option value="22">Espaillat</option>
<option value="34">Gaspar Hernandez</option>
<option value="31">Hato Mayor</option>
<option value="15">Independencia</option>
<option value="5">La Altagracia</option>
<option value="4">La Romana</option>
<option value="9">La Vega</option>
<option value="30">Maria Trinidad Sanchez</option>
<option value="24">Monse&ntilde;or Nouel</option>
<option value="27">Monte Plata</option>
<option value="19">Montecristi</option>
<option value="25">Ocoa</option>
<option value="13">Pedernales</option>
<option value="7">Peravia</option>
<option value="1">Puerto Plata</option>
<option value="23">Salcedo</option>
<option value="8">Samana</option>
<option value="26">San Cristobal</option>
<option value="16">San Juan</option>
<option value="6">San Pedro De Macoris</option>
<option value="28">Sanchez Ramirez</option>
<option value="10">Santiago</option>
<option value="20">Santiago Rodriguez</option>
<option value="3">Santo Domingo</option>
<option value="21">Valverde</option>
<option value="guerrero">guerrero</option>
<option value="tineo">tineo</option>
</select>
</td>
</tr>
<tr>
<td colspan="5"><select name="img" size="1" id="img">
<option value="azua">azua</option>
</select>
</td>
</tr>
<tr>
<td colspan="5"><select id="precio" name="precio" onchange="moneyRange('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"><select id="pmax" name="pmax" onchange="moneyRange('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="999999999">RD$ +50,000,000</option>
</select>
</td>
</tr>
<tr>
<td colspan="5"><img src="http://paradisso.com.do/reg/do/img/1x1.gif" border="0" height="10" width="1" /></td>
</tr>
<tr>
<td width="10"><input type="checkbox" />
</td>
<td colspan="4" align="left"> Solo propiedades con foto </td>
</tr>
<tr>
<td width="10"><input id="newonly" name="newonly" value="1" type="checkbox" />
</td>
<td colspan="4" align="left"> Solo propiedades nuevas </td>
</tr>
<tr>
<td width="10"><input id="trademode" name="trademode" value="b" checked="checked" onclick="togglePriceRange('b');" type="radio" />
</td>
<td align="left" width="50"> Comprar </td>
<td width="10"><input id="trademode" name="trademode" value="r" onclick="togglePriceRange('r');" type="radio" />
</td>
<td align="left"> Alquilar </td>
<td></td>
</tr>
<tr>
<td colspan="5"><img src="http://paradisso.com.do/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_bycode" id="srch_bycode" size="4" type="text" /></td>
</tr>
<tr>
<td colspan="5"><label for="Submit"></label>
<input type="submit" name="Submit2" value="buscar" id="Submit" /></td>
</tr>
</table>
</form>
</th>
</tr>
</table>
</body>
</html>
Mar 6 '07 #4

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


PLEASE HELP!!!
Mar 6 '07 #5

P: 5
THIS IS THE PHP code that searches for some of the options:

<?php
$dbh=mysql_connect ("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_escape_string()
$query = sprintf("SELECT * FROM friends WHERE tipoinmueble='$tipoinmueble' and localizacion='$localizacion'",
$result = mysql_query($sql,$conexio);

echo "<TABLE BORDER='0'>";
while ($row= mysql_fetch_array($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.....
Mar 6 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.