Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
i have seen in most of site like this
[url=http://imageshack.us][img]http://img167.imageshack.us/img167/3229/image1xc1.jpg[/img][/url]
i have this code to work for thisCode: Select all
<?php
$cb = @$_GET['cb'] ;//property type
$var = @$_GET['cid'] ;//price value if price is not all
$cb1 = @$_GET['cb1'] ;//area 0=all or else means not all
$cb2 = @$_GET['cb2'] ;//price returns 0 or < or > or =
$cb3 = @$_GET['cb3'] ;//property type 0 or 1=sale or 2=hire
$trimmed = trim($var); //trim whitespace from the stored variable
require_once ('../../dbconnect.php');
if ($cb1==0)//if area is any
{
if ($cb2==0)//price is all
{
if ($cb3==0)//type is any
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where properrty_type=$cb order by postedon desc";
}
else if($cb3==1) //type is not all but sale
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"sale\" order by postedon desc";
}
else //type is hire
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"hire\" order by postedon desc";
}
}
else //price not all,ie < > =
{
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}
if ($cb3==0)//type is any
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where properrty_type=$cb and price $cb2 $trimmed order by postedon desc";
}
else if($cb3==1) //type is not all but sale
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"sale\" and price $cb2 $trimmed order by postedon desc";
}
else //type is hire
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"hire\" and price $cb2 $trimmed order by postedon desc";
}
}//end of if price is < > =
}//end of if area==0
else //area is not any
{
if ($cb1==0)//if area is any
{
if ($cb2==0)//price is all
{
if ($cb3==0)//type is any
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where properrty_type=$cb order by postedon desc";
}
else if($cb3==1) //type is not all but sale
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"sale\" order by postedon desc";
}
else //type is hire
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"hire\" order by postedon desc";
}
}
else //price not all,ie < > =
{
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}
if ($cb3==0)//type is any
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where properrty_type=$cb and price $cb2 $trimmed order by postedon desc";
}
else if($cb3==1) //type is not all but sale
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"sale\" and price $cb2 $trimmed order by postedon desc";
}
else //type is hire
{
$query = "SELECT property_id,property_for,property_type,pdistrict,property_area,price,sdescription,postedon,views FROM realstate where property_type=$cb and property_for like \"hire\" and price $cb2 $trimmed order by postedon desc";
}
}//end of if price is < > =
}//end of else area==0
echo "<b><center><h2>Following users Found having name similar to<font color=red> <i>$trimmed</i></font></h2></center></b>";
echo "<center><i>click on telephone number for full details</i></center>";
echo '<table border="1" width="100%" cellspacing="3" cellpadding="3" align="center">
<tr>
<td align="left" width="15%" bgcolor=\"cyan\"><b>Property id</b></td>
<td align="left" width="20%" bgcolor=\"cyan\"><b>Property for</b></td>
<td align="left" width="10%" bgcolor=\"cyan\"><b>District</b></td>
<td align="left" width="5%" bgcolor=\"cyan\"><b>Area</b></td>
<td align="left" width="18%" bgcolor=\"cyan\"><b>Price</b></td>
<td align="left" width="25%" bgcolor=\"cyan\"><b>Views</b></td>
<td align="left" width="7%" bgcolor=\"cyan\"><b>Posted on</b></td>
</tr>';
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC))
{
if (mysql_num_rows($result) == 0)
{
echo "<p>No Result meeting this criterea!</p>";
exit();
}
else
{
echo " <tr>
<td align=\"left\"><a href=\"distotaltel.php?mid={$row['property_id']}\">{$row['property_id']}</a></td>
<td align=\"left\">{$row['property_for']}</td>
<td align=\"left\">{$row['pdistrict']}</td>
<td align=\"left\">{$row['property_area']}</td>
<td align=\"left\">{$row['price']}</td>
<td align=\"left\">{$row['views']}</td>
<td align=\"left\">{$row['postedon']}</td>
</tr>\n";
}
}
mysql_close();
?>but i myself couldnot agree with number of select and length of if and else
i think there is better way to do this ..
any suggestion
i made a decision tree and coded come out like this
as select are in if else i dont think it will put much pressure in database but any way too long..
any better way
if i now add one another thing it will be too complicated...
i myself found that rather than in that greater than ,less than ..i can put value
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]