473,395 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
Feb 25 '07 #1
5 1464
xwero
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
Thx, it is getting closer.
Feb 25 '07 #3
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
I want to search for some of those options or for all of them....


PLEASE HELP!!!
Mar 6 '07 #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

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

Similar topics

5
by: Frank | last post by:
Hello, I'm running a site with +20.000 articles. The articles (html files) are saved on the server as txt files. Alle other data (author, date, category and so on) are in a MySQL db. Before we...
0
by: only_me | last post by:
Not a coding question as such but highly related to asp/dynamic pages issues : has anyone any suggestions on the following ASP sites are generally (always) of a dynamic nature, pages can be...
10
by: Doc | last post by:
I've come across the concept of registering a website with search engines. Will you website not show up on Yahoo, Google, etc. based on keyword hits unless you're registered?
5
by: ken ullman | last post by:
1. what is robots.txt. I am looking at my log file and have been noticing that this file is not found..who creates it or how does it get created? 2. How do I get my web site to be recognized by...
14
by: vic | last post by:
My manager wants me to develop a search program, that would work like they have it at edorado.com. She made up her requirements after having compared how search works at different websites, like...
8
by: Stromboli | last post by:
Hi, I have my site available in a couple of languages most of the files are indexf.html (french), indexi.html (italian) and indexde.html (german).. I'd like to start using multiviews but I've...
83
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd...
16
by: Kent Feiler | last post by:
If I understand the general direction of recent posts, the idea is to improve the quality of html/css by soliciting help from the various browsers. Browsers can certainly detect problems but they...
0
by: passion | last post by:
"Specialized Search Engines" along with Google Search Capability (2 in 1): http://specialized-search-engines.blogspot.com/ Billions of websites are available on the web and plenty of extremely...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.