Page 1 of 1
I would like to make a search system like in this site
Posted: Sat Dec 21, 2002 2:02 pm
by clintwa
Hey everyone,
I been hired to create a real estate site and came across this site that has a search system that I would like to incorporate into my site.
http://www.mcgrath.com.au/
I would like to do in php and MySQL. I would like any suggestion or help in making a script like this. I have search most php site for information and unable to get anything that would help me.
Thanks,
Clint
Posted: Sat Dec 21, 2002 4:21 pm
by evilcoder
What sort of database are you running as a backend in your site?
Posted: Sat Dec 21, 2002 4:26 pm
by clintwa
The database will be MySQL.
Any advice would help
Thanks
Posted: Sat Dec 21, 2002 4:30 pm
by evilcoder
OK whats your time zone?? Where do you live?
Posted: Sun Dec 22, 2002 10:43 am
by clintwa
I live in Charleston, SC - eastern time zone
Search
Posted: Mon Dec 23, 2002 1:57 am
by serambin
Hi,
Looking at the site you mentioned, a few things may be the case. First, it looks like they are using a field for each major section of town for each listing. The check boxes are pre defined queries yielding all results of each area.
I think I would use the same idea for the --Street or Subdivision -- search as well. That is I woiuld use a 'Keyword' search using 2 fields. One field for the street name and one for the subdivion or area. The database search could look something like this:
Code: Select all
<? $conn = dbconnection();
if ($keyword) { //Keyword is the input in the text box.
$k = split(" ", $keyword);
$num_keywords = count($k); // For scoring the list of results.
for ($i=0; $i<$num_keywords; i++) {
if ($i)
$k_string .= "or k.keyword = ' ".$kї$i]. " ' " ;
else
$k_string .= "k.keyword = ' ".$kї$i] . " ' " ;
}
$and .= " and ($k_string) " ;
}
$sql = "select s.id, // Primary key in database.
s.area, // Area (subdivision) field.
10 * sum(k.weight) / $num_keywords as score
from streets s, keywords k
where s.id = k.streets
$and
group by s.id, s.area
order by score desc, s.id desc";
$result = mysql_query($sql, $conn);
// Now out results
echo "<H2>Here are the results</H2
if (mysql_num_rows($results)) {
echo "<TABLE>";
while ($qry = mysql_fetch_array($result)) {
echo "<TR><TD>";
echo $qryїarea];
echo "</TD><TD>;
echo floor($qryїscore])."%";
echo "/TD></TR>;
}
echo "</TABLE>";
else {
echo "No match found, try again.";
};
?>
Hope this helps,
Stan Rambin