Jump to content

If statement


le007

Recommended Posts

if ($property_type== "%"){

$sql = "SELECT * FROM `tabl` WHERE `property_type` like 'Agricultural Land' OR `property_type` like 'Business' OR `property_type` like 'Cafe/Deli' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";

} elseif ($property_type != "%"){

$sql = "SELECT * FROM `tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";

}

 

 

NOT working? Anyone know a fix? Thanks

Link to comment
Share on other sites

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Ok I put that in:

 

if ($property_type == "%"){

$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like 'Agricultural Land' OR `property_type` like 'Business' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";

$sirsql = mysql_query($sql) or die(mysql_error());

} elseif ($property_type != "%"){

$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";

$sirsql = mysql_query($sql) or die(mysql_error());

}

 

but the IF statement now isnt working - its just showing ALL results if $property_type == "%", it doesnt just show agricultural land, and business which is what its meant to do... any suggestions?

 

Thanks again

Link to comment
Share on other sites

<Style>

#divpn{
background: yellow;
width: 110px;
float: left;
}

#divnp{
background: yellow;
width: 110px;
float: left;
}

</style>

<br>
<center>
<img src="headimage/searchr.png" title="Search Results">
<hr width="520px" color="#650066">


<table cellspacing="0" cellpadding="10%" class="feat" width="520px" height="600px">

<tr>
<td valign="top">


<font size=2 face="arial" color="#65066">


<center>
<?php

//define variables
$border="0";

//connects to database etc.
include("config.php");

//set dbtotal variable - it's the total number of rows on the MySQL table
$ark = mysql_query("SELECT * FROM `cheap_tabl`") or die(mysql_error());
$dbtotal = mysql_num_rows($ark);

//get variables from url
$countycode = $_REQUEST['cp_county'];
$townnumber = $_REQUEST['cp_town'];
$minprice = $_REQUEST['minprice'];
$maxprice = $_REQUEST['maxprice'];
$minbeds = $_REQUEST['minbeds'];
$maxbeds = $_REQUEST['maxbeds'];
$prop_type = $_REQUEST['srch_property_type'];

// if county is not specified then search for everything:
if ($countycode == ""){
	$countycode="%";
	$town="%";
	    }

if ($countycode == "%"){
	$town="%";
	    }

//find out which town is town_number
$sqlcakefred = "SELECT * FROM `townsandcounties` where `countycode` like '". $countycode ."'";
$flib = mysql_query($sqlcakefred) or die(mysql_error());

$total_towns = 1;
while($row = mysql_fetch_array($flib)){
$j = $j + 1;
if ( $j == $townnumber ) {$town=$row['town'];$area=$row['county'];}

if ( ($area == '') && ($town=='') ){
$town="%";
$area=$row['county'];
}
// if townnumber is 0 then they searched for all properties within a county:
if ($townnumber == 0) {$county = $row['county'];}
$county=$row['county'];

}

if ($countycode=="%"){ $county='%';}




// Basically, if the page number is not specified, start with page 1 (i.e. set $page as 1),
// otherwise set $page as whatever the page number is set as in the url
if(!isset($_REQUEST['page'])){
    $page = 1;
} else {
$page = $_REQUEST['page']; 
}

//TOP SITEMAP
include("sitemap2.php");

// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);  


//this is the split between the sitemap at the top and the start of results. add as many <BR> as you like
echo "<BR>";

// start a table for query results
echo "<table border='" . $border . "'>";

/* -------------------- START MAIN QUERY -------------------- */

if ($prop_type == "%"){
$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like 'Agricultural Land' OR `property_type` like 'Business' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());
} elseif ($prop_type != "%"){
$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());
}

// Perform MySQL query on only the current page number's results


/* -------------------- END MAIN QUERY -------------------- */

//start the loop
while($row = mysql_fetch_array($sirsql)){

$resultnum++;
$resultnumber = ($max_results * ($page-1)) +$resultnum;

// MAIN STRINGS
$id=$row['cheap_id'];
$agent=$row['agent'];
$address=$row['address'];
$town_city=$row['town_city'];
$bedrooms=$row['bedrooms'];
$area=$row['area'];
$price=$row['price'];
$description=$row['description'];
$numberofpics=$row['number_of_images'];
$property_type=$row['property_type'];
// END MAIN STRINGS

$numberofadditionalpics = $numberofpics - 1;

// add commas to price
$priceshow = preg_replace('/(?<=\d)(?=(\d\d\d)+$)/', ',', $price);

// the reason for this next string is so that the sitemap knows that when you go
//to vproperty.php that you were passed from viewresults.php - check the if
//statement on viewproperty in sitemap2.php in order for it to make more sense
$vr=1;


//connect to users database and get info on the agent
$sqltwo = "SELECT * FROM `users` where `login` = '$agent'";
$resulttwo = mysql_query($sqltwo) or die(mysql_error());
$rowtwo = mysql_fetch_array($resulttwo);

$agencyname=$rowtwo['agencyname'];
$agencyemail=$rowtwo['email'];
$agencyweb=$rowtwo['web'];

//if $agencyweb is missing http:// , then add it
if ( (!strpos($agencyweb, "ttp://")) && ($agencyweb) ) {$agencyweb="http://".$agencyweb;}


// split the description up - take only first 100 letters. then add "...."
$description_short=substr($description, 0, 100) . "....";

//word wrap the description
$description_short = wordwrap($description_short, 25, "\n", true);

/*    -------------------- START TABLE ----------------------- */ 


echo <<<HERE






</b>
<table class="resultstable">

<tr>
<td style="border-bottom: 1px #650066 solid;" bgcolor="#669ACC" colspan="2" align="center">
<font color="white" face="arial" size="2"><u>
<b>SEARCH RESULT #$resultnumber</b>
</TD>
</tr>

<tr>
<td valign="top" align="left" width="50%" style="padding-top:5px; padding-left: 10px;">
<b>$address</b> - $town_city, $area
<br>
<b>$property_type
<br>
<b>Bedrooms: </b></b>$bedrooms
<br>
<b>Asking Price:</b></b> € $priceshow
<br>
<br>
</b>$description_short
<br>
<br>
<b>Property #</b> $id
<br>
<b><font face="verdana" size="1">$agencyname</b>
<br>
<a href="mailto:$agencyemail">$agencyemail</a>
<br>
<a target="new" href="$agencyweb">$agencyweb</a>

</td>


<td align="center" valign="top" style="padding-top:10px;">
<p class="resultimage">
<a 

href="index.php?locate=viewproperty&area=$townnamez&prop=$id&srch_property_type=$prop_type&cp_county=$countycode&cp_town=$townnumber&page=$page&minprice=$min

price&maxprice=$maxprice&minbeds=$minbeds&maxbeds=$maxbeds&vr=$vr">
HERE;

$mainimage = "images/prop". $id . "_1.jpg";

if ( (file_exists($mainimage)) && ($numberofpics > 0) ) {
echo "<img src='imgsize.php?w=188&h=140&constrain=1&img=images/prop" . $id . "_1.jpg' border='2' width='210' height='162'></a></p>";}
else {
echo "<img src='imgsize.php?w=188&h=140&constrain=1&img=images/noimages.jpg' border='2' width='210' height='162'></a></p>";
$numberofpics=0;
}




ECHO <<<HERE

<font color="#650066" face="arial" size="2">
HERE;

//-----------------------------------------------------------------------------------------
// Say 1 photo only or tell how many additional photos, if not logged in.
if(!isset($_SESSION["loggedIn"]))
{

if ($numberofadditionalpics == 0)
{
echo "<a 

href='index.php?locate=viewproperty&area=$townnamez&prop=$id&srch_property_type=$prop_type&cp_county=$countycode&cp_town=$townnumber&page=$page&minprice=$min

price&maxprice=$maxprice&minbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><b>1 Photo Only</a></b>";
}
if (($numberofadditionalpics > 0) && ($numberofpics > 0))
{
	echo "<a 

href='index.php?locate=viewproperty&area=$townnamez&prop=$id&srch_property_type=$prop_type&cp_county=$countycode&cp_town=$townnumber&page=$page&minprice=$min

price&maxprice=$maxprice&minbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><b>$numberofadditionalpics Additional Photos</a></b>";
}


}


//-----------------------------------------------------------------------------------------

// This next include box is a members box with an edit pencil and a red x for delete
// this should only appear if logged in as a member, oh and if you are the uploader
// of the property (correct agent)
if(isset($_SESSION["loggedIn"]) && (($agent == $_SESSION["login"]) or ($_SESSION["login"] == "administrator"))){
include ("resmembox1.inc.php");
}
ECHO <<<HERE

</td>

</tr>

</table>		



HERE;

//this is the split between each property, add as many <BR> as you like
echo "<BR>";
}



/*    -------------------- END TABLE ----------------------- */

/*    -------------------- START PAGINATION LINKS ----------------------- */

// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and 

`town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1)"),0);

if ($total_results > 0) {
echo "<b>TOTAL RESULTS=$total_results</b><br>";
}

// ***********The No results Error************
if ($total_results == 0) {
include ("no_search_results.php");
}
else
{

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

//show where you are
if ($total_results > 0){
echo "Page $page of $total_pages [$max_results max results per page]<br>";
}

// Build Page Number Hyperlinks
if ($total_pages > 1){echo "<center><p class='speciallink'><b><u>Select a Page</b></u><br><br>";}




// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a 

href='index.php?locate=viewresults&srch_property_type=$prop_type&cp_town=$townnumber&cp_county=$countycode&page=$prev&minprice=$minprice&maxprice=$maxprice&m

inbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><font size='3'><B><<Previous</B></a> </font>";
}



if ($total_pages > 1){
$lowend=$page-3;
$topend=$page+3;
for($i = $lowend; $i <= $topend; $i++){
if(($i>0)&&($i<($total_pages+1))){
if(($page) == $i){
		echo "<font size='3'><B>$i</B></font> ";
	} else {
		echo "<a 

href='index.php?locate=viewresults&srch_property_type=$prop_type&cp_town=$townnumber&cp_county=$countycode&page=$i&minprice=$minprice&maxprice=$maxprice&minb

eds=$minbeds&maxbeds=$maxbeds&vr=$vr'>$i</a> ";
	}
}
	}
}
// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a 

href='index.php?locate=viewresults&srch_property_type=$prop_type&cp_town=$townnumber&cp_county=$countycode&page=$next&minprice=$minprice&maxprice=$maxprice&m

inbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><font size='3'><b>Next>></b></font></a>";
}



//end of pagination
echo "</center>";  
/*    -------------------- END PAGINATION LINKS ----------------------- */
}
// end of MIDDLE. Close off table
echo "</table>";


?>


</table>

Link to comment
Share on other sites

Original problem anybody help?? IF statement not working... It doesnt just show Agricultural and Business if $prop_type eqauls %

 

if ($prop_type == "%"){

 

$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like 'Agricultural Land' OR `property_type` like 'Business' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";

$sirsql = mysql_query($sql) or die(mysql_error());

 

} elseif ($prop_type != "%"){

 

$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";

$sirsql = mysql_query($sql) or die(mysql_error());

 

}

Link to comment
Share on other sites

for debug try to echo $sql

if ($prop_type == "%"){

echo $sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like 'Agricultural Land' OR `property_type` like 'Business' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());

} elseif ($prop_type != "%"){

echo $sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());

}

Link to comment
Share on other sites

Thanks for that I've included it. The !== % works at the moment. The problem is if someone clicks ALL props (%) it still doesnt just show what I want - it shows everything... anyone any ideas pls?

 

if ($prop_type == "%"){

$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like 'House' OR `property_type` like 'Site' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());

} elseif ($prop_type !== "%"){

$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());

}

Link to comment
Share on other sites

your where part of $sql select all rovs where propert_type = 'House' and all rows where `property_type` like 'Site' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1)

 

doe's it what you want

i think zhat you want

$sql = "SELECT * FROM `cheap_tabl` WHERE (`property_type` like 'House' OR `property_type` like 'Site') and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";

 

Link to comment
Share on other sites

Thanks for the replies - I really thought the brackets () was it! But it wasn't...

 

basically the problem is, people have a an option to search for specific property types (houses, sites, offices, apartments, land, etc). When they click on say HOUSE it works fine, it just shows houses in the results but if they click search and dont specify a property type eg(%) EVERYTHING comes up and I only want "Sites" and "Houses" to appear in the results. (Long story but thats all I want to show)

 

Anyone other ideas? Many thanks everyone

Link to comment
Share on other sites

Won't work cos I have to allow the user search for all property types - its an option they must have. Its in a loop too, I just want the query to skip anything that doesnt have house or site in it!

 

thanks again for your help - just dunno how to get this result...

Link to comment
Share on other sites

<Style>

#divpn{
background: yellow;
width: 110px;
float: left;
}

#divnp{
background: yellow;
width: 110px;
float: left;
}

</style>

<br>
<center>
<img src="headimage/searchr.png" title="Search Results">
<hr width="520px" color="#650066">


<table cellspacing="0" cellpadding="10%" class="feat" width="520px" height="600px">

<tr>
<td valign="top">


<font size=2 face="arial" color="#65066">


<center>
<?php

//define variables
$border="0";

//connects to database etc.
include("config.php");

//set dbtotal variable - it's the total number of rows on the MySQL table
$ark = mysql_query("SELECT * FROM `cheap_tabl`") or die(mysql_error());
$dbtotal = mysql_num_rows($ark);

//get variables from url
$countycode = $_REQUEST['cp_county'];
$townnumber = $_REQUEST['cp_town'];
$minprice = $_REQUEST['minprice'];
$maxprice = $_REQUEST['maxprice'];
$minbeds = $_REQUEST['minbeds'];
$maxbeds = $_REQUEST['maxbeds'];
$prop_type = $_REQUEST['srch_property_type'];

// if county is not specified then search for everything:
if ($countycode == ""){
	$countycode="%";
	$town="%";
	    }

if ($countycode == "%"){
	$town="%";
	    }

//find out which town is town_number
$sqlcakefred = "SELECT * FROM `townsandcounties` where `countycode` like '". $countycode ."'";
$flib = mysql_query($sqlcakefred) or die(mysql_error());

$total_towns = 1;
while($row = mysql_fetch_array($flib)){
$j = $j + 1;
if ( $j == $townnumber ) {$town=$row['town'];$area=$row['county'];}

if ( ($area == '') && ($town=='') ){
$town="%";
$area=$row['county'];
}
// if townnumber is 0 then they searched for all properties within a county:
if ($townnumber == 0) {$county = $row['county'];}
$county=$row['county'];

}

if ($countycode=="%"){ $county='%';}




// Basically, if the page number is not specified, start with page 1 (i.e. set $page as 1),
// otherwise set $page as whatever the page number is set as in the url
if(!isset($_REQUEST['page'])){
    $page = 1;
} else {
$page = $_REQUEST['page']; 
}

//TOP SITEMAP
include("sitemap2.php");

// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);  


//this is the split between the sitemap at the top and the start of results. add as many <BR> as you like
echo "<BR>";

// start a table for query results
echo "<table border='" . $border . "'>";

/* -------------------- START MAIN QUERY -------------------- */

if ($prop_type == "%"){
$sql = "SELECT * FROM `cheap_tabl` WHERE (`property_type` like 'House' OR `property_type` like 'Site') and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());
} elseif ($prop_type !== "%"){
$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());
}

// Perform MySQL query on only the current page number's results


/* -------------------- END MAIN QUERY -------------------- */

//start the loop
while($row = mysql_fetch_array($sirsql)){

$resultnum++;
$resultnumber = ($max_results * ($page-1)) +$resultnum;

// MAIN STRINGS
$id=$row['cheap_id'];
$agent=$row['agent'];
$address=$row['address'];
$town_city=$row['town_city'];
$bedrooms=$row['bedrooms'];
$area=$row['area'];
$price=$row['price'];
$description=$row['description'];
$numberofpics=$row['number_of_images'];
$property_type=$row['property_type'];
// END MAIN STRINGS

$numberofadditionalpics = $numberofpics - 1;

// add commas to price
$priceshow = preg_replace('/(?<=\d)(?=(\d\d\d)+$)/', ',', $price);

// the reason for this next string is so that the sitemap knows that when you go
//to vproperty.php that you were passed from viewresults.php - check the if
//statement on viewproperty in sitemap2.php in order for it to make more sense
$vr=1;


//connect to users database and get info on the agent
$sqltwo = "SELECT * FROM `users` where `login` = '$agent'";
$resulttwo = mysql_query($sqltwo) or die(mysql_error());
$rowtwo = mysql_fetch_array($resulttwo);

$agencyname=$rowtwo['agencyname'];
$agencyemail=$rowtwo['email'];
$agencyweb=$rowtwo['web'];

//if $agencyweb is missing http:// , then add it
if ( (!strpos($agencyweb, "ttp://")) && ($agencyweb) ) {$agencyweb="http://".$agencyweb;}


// split the description up - take only first 100 letters. then add "...."
$description_short=substr($description, 0, 100) . "....";

//word wrap the description
$description_short = wordwrap($description_short, 25, "\n", true);

/*    -------------------- START TABLE ----------------------- */ 


echo <<<HERE






</b>
<table class="resultstable">

<tr>
<td style="border-bottom: 1px #650066 solid;" bgcolor="#669ACC" colspan="2" align="center">
<font color="white" face="arial" size="2"><u>
<b>SEARCH RESULT #$resultnumber</b>
</TD>
</tr>

<tr>
<td valign="top" align="left" width="50%" style="padding-top:5px; padding-left: 10px;">
<b>$address</b> - $town_city, $area
<br>
<b>$property_type
<br>
<b>Bedrooms: </b></b>$bedrooms
<br>
<b>Asking Price:</b></b> € $priceshow
<br>
<br>
</b>$description_short
<br>
<br>
<b>Property #</b> $id
<br>
<b><font face="verdana" size="1">$agencyname</b>
<br>
<a href="mailto:$agencyemail">$agencyemail</a>
<br>
<a target="new" href="$agencyweb">$agencyweb</a>

</td>


<td align="center" valign="top" style="padding-top:10px;">
<p class="resultimage">
<a 

href="index.php?locate=viewproperty&area=$townnamez&prop=$id&srch_property_type=$prop_type&cp_county=$countycode&cp_town=$townnumber&page=$page&minprice=$min

price&maxprice=$maxprice&minbeds=$minbeds&maxbeds=$maxbeds&vr=$vr">
HERE;

$mainimage = "images/prop". $id . "_1.jpg";

if ( (file_exists($mainimage)) && ($numberofpics > 0) ) {
echo "<img src='imgsize.php?w=188&h=140&constrain=1&img=images/prop" . $id . "_1.jpg' border='2' width='210' height='162'></a></p>";}
else {
echo "<img src='imgsize.php?w=188&h=140&constrain=1&img=images/noimages.jpg' border='2' width='210' height='162'></a></p>";
$numberofpics=0;
}




ECHO <<<HERE

<font color="#650066" face="arial" size="2">
HERE;

//-----------------------------------------------------------------------------------------
// Say 1 photo only or tell how many additional photos, if not logged in.
if(!isset($_SESSION["loggedIn"]))
{

if ($numberofadditionalpics == 0)
{
echo "<a 

href='index.php?locate=viewproperty&area=$townnamez&prop=$id&srch_property_type=$prop_type&cp_county=$countycode&cp_town=$townnumber&page=$page&minprice=$min

price&maxprice=$maxprice&minbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><b>1 Photo Only</a></b>";
}
if (($numberofadditionalpics > 0) && ($numberofpics > 0))
{
	echo "<a 

href='index.php?locate=viewproperty&area=$townnamez&prop=$id&srch_property_type=$prop_type&cp_county=$countycode&cp_town=$townnumber&page=$page&minprice=$min

price&maxprice=$maxprice&minbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><b>$numberofadditionalpics Additional Photos</a></b>";
}


}


//-----------------------------------------------------------------------------------------

// This next include box is a members box with an edit pencil and a red x for delete
// this should only appear if logged in as a member, oh and if you are the uploader
// of the property (correct agent)
if(isset($_SESSION["loggedIn"]) && (($agent == $_SESSION["login"]) or ($_SESSION["login"] == "administrator"))){
include ("resmembox1.inc.php");
}
ECHO <<<HERE

</td>

</tr>

</table>		



HERE;

//this is the split between each property, add as many <BR> as you like
echo "<BR>";
}



/*    -------------------- END TABLE ----------------------- */

/*    -------------------- START PAGINATION LINKS ----------------------- */

// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and 

`town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1)"),0);

if ($total_results > 0) {
echo "<b>TOTAL RESULTS=$total_results</b><br>";
}

// ***********The No results Error************
if ($total_results == 0) {
include ("no_search_results.php");
}
else
{

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

//show where you are
if ($total_results > 0){
echo "Page $page of $total_pages [$max_results max results per page]<br>";
}

// Build Page Number Hyperlinks
if ($total_pages > 1){echo "<center><p class='speciallink'><b><u>Select a Page</b></u><br><br>";}




// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a 

href='index.php?locate=viewresults&srch_property_type=$prop_type&cp_town=$townnumber&cp_county=$countycode&page=$prev&minprice=$minprice&maxprice=$maxprice&m

inbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><font size='3'><B><<Previous</B></a> </font>";
}



if ($total_pages > 1){
$lowend=$page-3;
$topend=$page+3;
for($i = $lowend; $i <= $topend; $i++){
if(($i>0)&&($i<($total_pages+1))){
if(($page) == $i){
		echo "<font size='3'><B>$i</B></font> ";
	} else {
		echo "<a 

href='index.php?locate=viewresults&srch_property_type=$prop_type&cp_town=$townnumber&cp_county=$countycode&page=$i&minprice=$minprice&maxprice=$maxprice&minb

eds=$minbeds&maxbeds=$maxbeds&vr=$vr'>$i</a> ";
	}
}
	}
}
// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a 

href='index.php?locate=viewresults&srch_property_type=$prop_type&cp_town=$townnumber&cp_county=$countycode&page=$next&minprice=$minprice&maxprice=$maxprice&m

inbeds=$minbeds&maxbeds=$maxbeds&vr=$vr'><font size='3'><b>Next>></b></font></a>";
}



//end of pagination
echo "</center>";  
/*    -------------------- END PAGINATION LINKS ----------------------- */
}
// end of MIDDLE. Close off table
echo "</table>";


?>


</table>

Link to comment
Share on other sites

no wonder it shows everything you have it so if its set ot false it displays everything

} elseif ($prop_type !== "%"){
$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type`
like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` 
< ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.