satmanuk
asked on
Help with search using check boxes - PHP MYSQL
Hi all,
I am working on a site using PHP and mysql.
I have a page where records are being displayed (max 10 per page). The page lists houses with various details on each house.
I want to make a search feature on the side of the page where i can search for houses at certain price ranges. I have added 5 check boxes and 2 tick boxes in a form but i am not sure what the best way is to go about integrating the search with my existing code.
Here how i plan to use the check boxes:
Check box 1 - Show all from table
Check box 2 - Show all below 150,000
Check box 3 - Show all betwenn 150,000 and 250,000
Check box 4 Show all between 250,000 and 350,000
Check box 5 show all over 350,000
I also want to give the option to only show new houses and the option to not show Sold houses.
I am looking to get some advice how best to integrate this idea.
My code:
<?php require_once('Connections/ EE_con.php '); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Reco rdset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1' ];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_ EE_con, $EE_con);
$query_Recordset1 = "SELECT * FROM properties";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_R ecordset1, $EE_con) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Records et1);
if (isset($_GET['totalRows_Re cordset1'] )) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset 1'];
} else {
$all_Recordset1 = mysql_query($query_Records et1);
$totalRows_Recordset1 = mysql_num_rows($all_Record set1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1 /$maxRows_ Recordset1 )-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST RING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record set1=%d%s" , $totalRows_Recordset1, $queryString_Recordset1);
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST RING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record set1=%d%s" , $totalRows_Recordset1, $queryString_Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>For Sale</title>
<style type="text/css" media="screen">
<!--
@import url("p7pm/p7pmh14.css");
@import url("bartstyles/bart2colfl uidh.css") ;
-->
</style>
<!--[if lte IE 6]>
<style type="text/css">
a {height: 1em;}
#pagewrapper{
width:expression(parseInt( this.curre ntStyle.ma rginLeft)+ parseInt(t his.curren tStyle.mar ginRight)- document.b ody.client Width>=-72 0?"720px": "auto");}
</style>
<![endif]-->
<!--[if IE 5]>
<style type="text/css">
#copyrightdiv {margin-top: -20px;}
</style>
<![endif]-->
</head>
<body>
<div id="pagewrapper">
<div id="masthead">
<div id="logodiv">
<img src="images/barthz_logo.jp g" alt="Bartlett - Established 1884 in New York City" width="273" height="130"></div>
</div>
<div id="menubar">
<ul id="p7PMnav">
<li><a href="aboutus.php">About Us </a></li>
<li><a href="forsale.php">Propert y For Sale </a></li>
<li><a href="forrent.php">Propert y For Rent </a></li>
<li><a href="contactus.php">Conta ct Us </a></li>
</ul>
<div class="clearmenu"> </ div>
</div>
<div id="mainbox">
<div id="sidebar">
<h3 class="top"><a href="admin.php">Admin</a> </h3>
<form name="form1" method="post" action="">
<p> </p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>All Properties </strong></p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>up to £150,000 </strong></p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>£150,000 - £250,000</strong> </p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>£250,000 - £350,000</strong> </p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>£350,000 and above </strong></p>
<p>
<input type="checkbox" name="checkbox" value="checkbox">
<strong> Exclude Sold properties </strong></p>
<p>
<input type="checkbox" name="checkbox2" value="checkbox">
<strong>New Properties Only </strong></p>
<p>
<input type="submit" name="Submit" value="Search">
</p>
</form>
<p> </p>
</div>
<div id="maincontent">
<h1>Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?></h1>
<p align="center"><a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a> <a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, min($totalPages_Recordset1 , $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a></p>
<table width="500" border="0" align="center">
<?php do { ?>
<tr>
<td rowspan="2"><a href="detail.php?recordID= <?php echo $row_Recordset1['propertyi d']; ?>"><img src="<?php echo $row_Recordset1['pic1']; ?>" width="180" height="180" border="0" /></a></td>
<td><?php echo $row_Recordset1['propertyn ame']; ?></td>
</tr>
<tr>
<td><?php echo $row_Recordset1['propertyd esc']; ?></td>
</tr>
<tr>
<td><a href="update.php?propertyi d=<?php echo $row_Recordset1['propertyi d']; ?>">Update</a></td>
<td><a href="confirmDelete.php?pr opertyid=< ?php echo $row_Recordset1['propertyi d']; ?>">Delete</a></td>
</tr>
<tr>
<td> <a href="detail.php?recordID= <?php echo $row_Recordset1['propertyi d']; ?>"><?php echo $row_Recordset1['prop_deta il']; ?></a></td>
<td>£<?php echo $row_Recordset1['price']; ?></td>
</tr>
<tr>
<td colspan="2"><a href="detail.php?recordID= <?php echo $row_Recordset1['propertyi d']; ?>"></a>__________________ __________ __________ __________ _________< /td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Records et1)); ?>
</table>
<br>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, min($totalPages_Recordset1 , $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p></p>
</div>
</div>
<div id="copyrightdiv">
<div id="copyrightnotice">
<img src="images/barthz_copyrig ht.jpg" alt="Copyright 2005" width="292" height="26"></div>
</div>
<div id="footer">
<p>Blah, LTD. Phone: 0800 000000 Fax: 0800 000000 </p>
<p>Contact Information | Press Releases</p>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($Records et1);
?>
Hope you can help
TIA
I am working on a site using PHP and mysql.
I have a page where records are being displayed (max 10 per page). The page lists houses with various details on each house.
I want to make a search feature on the side of the page where i can search for houses at certain price ranges. I have added 5 check boxes and 2 tick boxes in a form but i am not sure what the best way is to go about integrating the search with my existing code.
Here how i plan to use the check boxes:
Check box 1 - Show all from table
Check box 2 - Show all below 150,000
Check box 3 - Show all betwenn 150,000 and 250,000
Check box 4 Show all between 250,000 and 350,000
Check box 5 show all over 350,000
I also want to give the option to only show new houses and the option to not show Sold houses.
I am looking to get some advice how best to integrate this idea.
My code:
<?php require_once('Connections/
<?php
$currentPage = $_SERVER["PHP_SELF"];
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Reco
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_
$query_Recordset1 = "SELECT * FROM properties";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_R
$row_Recordset1 = mysql_fetch_assoc($Records
if (isset($_GET['totalRows_Re
$totalRows_Recordset1 = $_GET['totalRows_Recordset
} else {
$all_Recordset1 = mysql_query($query_Records
$totalRows_Recordset1 = mysql_num_rows($all_Record
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>For Sale</title>
<style type="text/css" media="screen">
<!--
@import url("p7pm/p7pmh14.css");
@import url("bartstyles/bart2colfl
-->
</style>
<!--[if lte IE 6]>
<style type="text/css">
a {height: 1em;}
#pagewrapper{
width:expression(parseInt(
</style>
<![endif]-->
<!--[if IE 5]>
<style type="text/css">
#copyrightdiv {margin-top: -20px;}
</style>
<![endif]-->
</head>
<body>
<div id="pagewrapper">
<div id="masthead">
<div id="logodiv">
<img src="images/barthz_logo.jp
</div>
<div id="menubar">
<ul id="p7PMnav">
<li><a href="aboutus.php">About Us </a></li>
<li><a href="forsale.php">Propert
<li><a href="forrent.php">Propert
<li><a href="contactus.php">Conta
</ul>
<div class="clearmenu"> </
</div>
<div id="mainbox">
<div id="sidebar">
<h3 class="top"><a href="admin.php">Admin</a>
<form name="form1" method="post" action="">
<p> </p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>All Properties </strong></p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>up to £150,000 </strong></p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>£150,000 - £250,000</strong> </p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>£250,000 - £350,000</strong> </p>
<p>
<input name="radiobutton" type="radio" value="radiobutton">
<strong>£350,000 and above </strong></p>
<p>
<input type="checkbox" name="checkbox" value="checkbox">
<strong> Exclude Sold properties </strong></p>
<p>
<input type="checkbox" name="checkbox2" value="checkbox">
<strong>New Properties Only </strong></p>
<p>
<input type="submit" name="Submit" value="Search">
</p>
</form>
<p> </p>
</div>
<div id="maincontent">
<h1>Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?></h1>
<p align="center"><a href="<?php printf("%s?pageNum_Records
<table width="500" border="0" align="center">
<?php do { ?>
<tr>
<td rowspan="2"><a href="detail.php?recordID=
<td><?php echo $row_Recordset1['propertyn
</tr>
<tr>
<td><?php echo $row_Recordset1['propertyd
</tr>
<tr>
<td><a href="update.php?propertyi
<td><a href="confirmDelete.php?pr
</tr>
<tr>
<td> <a href="detail.php?recordID=
<td>£<?php echo $row_Recordset1['price']; ?></td>
</tr>
<tr>
<td colspan="2"><a href="detail.php?recordID=
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Records
</table>
<br>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p></p>
</div>
</div>
<div id="copyrightdiv">
<div id="copyrightnotice">
<img src="images/barthz_copyrig
</div>
<div id="footer">
<p>Blah, LTD. Phone: 0800 000000 Fax: 0800 000000 </p>
<p>Contact Information | Press Releases</p>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($Records
?>
Hope you can help
TIA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You know what? I think I may have misled you. Check out the format for html radio buttons at http://www.echoecho.com/htmlforms10.htm
The NAME for all the radio buttons should be the same, but the VALUE should be different...
<input name="priceradio" type="radio" value="Radio1">
<strong>All Properties </strong></p>
<p>
<input name="priceradio" type="radio" value="Radio2">
<strong>up to £150,000 </strong></p>
<p>
<input name="priceradio" type="radio" value="Radio3">
<strong>£150,000 - £250,000</strong> </p>
<p>
<input name="priceradio" type="radio" value="Radio4">
<strong>£250,000 - £350,000</strong> </p>
<p>
<input name="priceradio" type="radio" value="Radio5">
<strong>£350,000 and above </strong></p>
And then in your php,
if ($_GET['radioprice']=="rad io1")) {
$where_clause = "";
} elseif ($_GET['radioprice']=="rad io2")) {
$where_clause = "WHERE price < 150000";
} elseif ($_GET['radioprice']=="rad io3")) {
$where_clause = "WHERE price BETWEEN 150000 AND 250000";
} elseif ($_GET['radioprice']=="rad io4")) {
$where_clause = "WHERE price BETWEEN 250000 AND 350000";
} elseif ($_GET['radioprice']=="rad io5")) {
$where_clause = "WHERE price > 350000";
The NAME for all the radio buttons should be the same, but the VALUE should be different...
<input name="priceradio" type="radio" value="Radio1">
<strong>All Properties </strong></p>
<p>
<input name="priceradio" type="radio" value="Radio2">
<strong>up to £150,000 </strong></p>
<p>
<input name="priceradio" type="radio" value="Radio3">
<strong>£150,000 - £250,000</strong> </p>
<p>
<input name="priceradio" type="radio" value="Radio4">
<strong>£250,000 - £350,000</strong> </p>
<p>
<input name="priceradio" type="radio" value="Radio5">
<strong>£350,000 and above </strong></p>
And then in your php,
if ($_GET['radioprice']=="rad
$where_clause = "";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price < 150000";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price BETWEEN 150000 AND 250000";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price BETWEEN 250000 AND 350000";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price > 350000";
ASKER
Ok i tried that. Still doesnt work? i tried to echo out the where_clause but it shows nothing..
Any Ideas?
<?php require_once('Connections/ EE_con.php '); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Reco rdset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1' ];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_ EE_con, $EE_con);
if ($_GET['radioprice']=="rad io1") {
$where_clause = "";
} elseif ($_GET['radioprice']=="rad io2") {
$where_clause = "WHERE price < 150000";
} elseif ($_GET['radioprice']=="rad io3") {
$where_clause = "WHERE price BETWEEN 150000 AND 250000";
} elseif ($_GET['radioprice']=="rad io4") {
$where_clause = "WHERE price BETWEEN 250000 AND 350000";
} elseif ($_GET['radioprice']=="rad io5") {
$where_clause = "WHERE price > 350000";
}
$query_Recordset1 = "SELECT * FROM properties" . $where_clause;
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_R ecordset1, $EE_con) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Records et1);
if (isset($_GET['totalRows_Re cordset1'] )) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset 1'];
} else {
$all_Recordset1 = mysql_query($query_Records et1);
$totalRows_Recordset1 = mysql_num_rows($all_Record set1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1 /$maxRows_ Recordset1 )-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST RING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record set1=%d%s" , $totalRows_Recordset1, $queryString_Recordset1);
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST RING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record set1=%d%s" , $totalRows_Recordset1, $queryString_Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>For Sale</title>
<style type="text/css" media="screen">
<!--
@import url("p7pm/p7pmh14.css");
@import url("bartstyles/bart2colfl uidh.css") ;
-->
</style>
<!--[if lte IE 6]>
<style type="text/css">
a {height: 1em;}
#pagewrapper{
width:expression(parseInt( this.curre ntStyle.ma rginLeft)+ parseInt(t his.curren tStyle.mar ginRight)- document.b ody.client Width>=-72 0?"720px": "auto");}
</style>
<![endif]-->
<!--[if IE 5]>
<style type="text/css">
#copyrightdiv {margin-top: -20px;}
</style>
<![endif]-->
</head>
<body>
<div id="pagewrapper">
<div id="masthead">
<div id="logodiv">
<img src="images/barthz_logo.jp g" alt="Bartlett - Established 1884 in New York City" width="273" height="130"></div>
</div>
<div id="menubar">
<ul id="p7PMnav">
<li><a href="aboutus.php">About Us </a></li>
<li><a href="forsale.php">Propert y For Sale </a></li>
<li><a href="forrent.php">Propert y For Rent </a></li>
<li><a href="contactus.php">Conta ct Us </a></li>
</ul>
<div class="clearmenu"> </ div>
</div>
<div id="mainbox">
<div id="sidebar">
<h3 class="top"><a href="admin.php">Admin</a> </h3>
<form name="form1" method="post" action="forsale.php">
<p> </p>
<p>
<input name="radioprice" type="radio" value="radio1" checked />
<strong>All Properties </strong></p>
<p>
<input name="radioprice" type="radio" value="radio2" />
<strong>up to £150,000 </strong></p>
<p>
<input name="radioprice" type="radio" value="radio3" />
<strong>£150,000 - £250,000</strong> </p>
<p>
<input name="radioprice" type="radio" value="radio4" />
<strong>£250,000 - £350,000</strong> </p>
<p>
<input name="radioprice" type="radio" value="radio5" />
<strong>£350,000 and above </strong></p>
<p> </p>
<p>
<input type="submit" name="submit" value="Search" />
</p>
</form>
<p> </p>
</div>
<div id="maincontent">
<h1>Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?></h1>
<p align="center"><a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a> <a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, min($totalPages_Recordset1 , $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a></p>
<table width="500" border="0" align="center">
<?php do { ?>
<tr>
<td rowspan="2"><a href="detail.php?recordID= <?php echo $row_Recordset1['propertyi d']; ?>"><img src="<?php echo $row_Recordset1['pic1']; ?>" width="180" height="180" border="0" /></a></td>
<td><?php echo $row_Recordset1['propertyn ame']; ?></td>
</tr>
<tr>
<td><?php echo $row_Recordset1['propertyd esc']; ?></td>
</tr>
<tr>
<td><a href="update.php?propertyi d=<?php echo $row_Recordset1['propertyi d']; ?>">Update</a></td>
<td><a href="confirmDelete.php?pr opertyid=< ?php echo $row_Recordset1['propertyi d']; ?>">Delete</a></td>
</tr>
<tr>
<td> <a href="detail.php?recordID= <?php echo $row_Recordset1['propertyi d']; ?>"><?php echo $row_Recordset1['prop_deta il']; ?></a></td>
<td>£<?php echo $row_Recordset1['price']; ?></td>
</tr>
<tr>
<td colspan="2"><a href="detail.php?recordID= <?php echo $row_Recordset1['propertyi d']; ?>"></a>__________________ __________ __________ __________ _________< /td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Records et1)); ?>
</table>
<br>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, min($totalPages_Recordset1 , $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records et1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p></p>
</div>
</div>
<div id="copyrightdiv">
<div id="copyrightnotice">
<img src="images/barthz_copyrig ht.jpg" alt="Copyright 2005 Project Seven Development" width="292" height="26"></div>
</div>
<div id="footer">
<p>Baynham , LTD. Phone: 0800 000000 Fax: 0800 000000 </p>
<p>Contact Information | Press Releases</p>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($Records et1);
?>
Any Ideas?
<?php require_once('Connections/
<?php
$currentPage = $_SERVER["PHP_SELF"];
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Reco
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_
if ($_GET['radioprice']=="rad
$where_clause = "";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price < 150000";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price BETWEEN 150000 AND 250000";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price BETWEEN 250000 AND 350000";
} elseif ($_GET['radioprice']=="rad
$where_clause = "WHERE price > 350000";
}
$query_Recordset1 = "SELECT * FROM properties" . $where_clause;
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_R
$row_Recordset1 = mysql_fetch_assoc($Records
if (isset($_GET['totalRows_Re
$totalRows_Recordset1 = $_GET['totalRows_Recordset
} else {
$all_Recordset1 = mysql_query($query_Records
$totalRows_Recordset1 = mysql_num_rows($all_Record
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_ST
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Record
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>For Sale</title>
<style type="text/css" media="screen">
<!--
@import url("p7pm/p7pmh14.css");
@import url("bartstyles/bart2colfl
-->
</style>
<!--[if lte IE 6]>
<style type="text/css">
a {height: 1em;}
#pagewrapper{
width:expression(parseInt(
</style>
<![endif]-->
<!--[if IE 5]>
<style type="text/css">
#copyrightdiv {margin-top: -20px;}
</style>
<![endif]-->
</head>
<body>
<div id="pagewrapper">
<div id="masthead">
<div id="logodiv">
<img src="images/barthz_logo.jp
</div>
<div id="menubar">
<ul id="p7PMnav">
<li><a href="aboutus.php">About Us </a></li>
<li><a href="forsale.php">Propert
<li><a href="forrent.php">Propert
<li><a href="contactus.php">Conta
</ul>
<div class="clearmenu"> </
</div>
<div id="mainbox">
<div id="sidebar">
<h3 class="top"><a href="admin.php">Admin</a>
<form name="form1" method="post" action="forsale.php">
<p> </p>
<p>
<input name="radioprice" type="radio" value="radio1" checked />
<strong>All Properties </strong></p>
<p>
<input name="radioprice" type="radio" value="radio2" />
<strong>up to £150,000 </strong></p>
<p>
<input name="radioprice" type="radio" value="radio3" />
<strong>£150,000 - £250,000</strong> </p>
<p>
<input name="radioprice" type="radio" value="radio4" />
<strong>£250,000 - £350,000</strong> </p>
<p>
<input name="radioprice" type="radio" value="radio5" />
<strong>£350,000 and above </strong></p>
<p> </p>
<p>
<input type="submit" name="submit" value="Search" />
</p>
</form>
<p> </p>
</div>
<div id="maincontent">
<h1>Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?></h1>
<p align="center"><a href="<?php printf("%s?pageNum_Records
<table width="500" border="0" align="center">
<?php do { ?>
<tr>
<td rowspan="2"><a href="detail.php?recordID=
<td><?php echo $row_Recordset1['propertyn
</tr>
<tr>
<td><?php echo $row_Recordset1['propertyd
</tr>
<tr>
<td><a href="update.php?propertyi
<td><a href="confirmDelete.php?pr
</tr>
<tr>
<td> <a href="detail.php?recordID=
<td>£<?php echo $row_Recordset1['price']; ?></td>
</tr>
<tr>
<td colspan="2"><a href="detail.php?recordID=
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Records
</table>
<br>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Records
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p></p>
</div>
</div>
<div id="copyrightdiv">
<div id="copyrightnotice">
<img src="images/barthz_copyrig
</div>
<div id="footer">
<p>Baynham , LTD. Phone: 0800 000000 Fax: 0800 000000 </p>
<p>Contact Information | Press Releases</p>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($Records
?>
hmmm. ok, try echoing out radioprice... is it getting that? Probably not. I see that you have method=post, so you probably have to do $_POST['radioprice'] instead of $_GET
ASKER
Cool, that sorted it
Thanks
Thanks
ASKER
I am missing something as it isnt working as yet. I sorted the wrong spelling in the where clause and i gave the values a unique name on the form. I also changed cost to price as this matches the field name in the database. I added forsale.php to the action on the form as i belive this needs to be set the same as the page running the search
I have left the check boxes out of the query for now.
What have i missed?
I changed my code here:
mysql_select_db($database_
if (isset($_GET['Radio1'])) {
$where_clause = "";
} elseif (isset($_GET['Radio2'])) {
$where_clause = "WHERE price < 150000";
} elseif (isset($_GET['Radio3'])) {
$where_clause = "WHERE price BETWEEN 150000 AND 250000";
} elseif (isset($_GET['Radio4'])) {
$where_clause = "WHERE price BETWEEN 250000 AND 350000";
} elseif (isset($_GET['Radio5'])) {
$where_clause = "WHERE price > 350000";
}
$query_Recordset1 = "SELECT * FROM properties" . $where_clause;
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
and here:
<form name="form1" method="post" action="forsale.php">
<p> </p>
<p>
<input name="radiobutton1" type="radio" value="Radio1">
<strong>All Properties </strong></p>
<p>
<input name="radiobutton2" type="radio" value="Radio2">
<strong>up to £150,000 </strong></p>
<p>
<input name="radiobutton3" type="radio" value="Radio3">
<strong>£150,000 - £250,000</strong> </p>
<p>
<input name="radiobutton4" type="radio" value="Radio4">
<strong>£250,000 - £350,000</strong> </p>
<p>
<input name="radiobutton5" type="radio" value="Radio5">
<strong>£350,000 and above </strong></p>
<p>
<input type="checkbox" name="checkbox" value="checkbox">
<strong> Exclude Sold properties </strong></p>
<p>
<input type="checkbox" name="checkbox2" value="checkbox">
<strong>New Properties Only </strong></p>
<p>
<input type="submit" name="Submit" value="Search">
</p>
</form>