If you can help with sessions that would be great. I am looking through php cookbook....not helpful for a beginner!
newsearch.php
<form action="newcode.php" method="post">
<table border="0" width="63%" bgcolor="#FFFFCC">
<tr>
<td width="100%">
<table border="0" width="100%">
<tr>
<td width="20%" bgcolor="#FFFF99" align="center"><strong><font face="Tahoma" size="2">Town</font></strong></td>
<td width="20%" bgcolor="#FFFF99" align="center"><strong>
<font face="Tahoma" size="2">Price Range</font></strong></td>
<td width="20%" bgcolor="#FFFF99" align="center"><strong>
<font face="Tahoma" size="2">Bed Rooms</font></strong></td>
<td width="20%" bgcolor="#FFFF99" align="center"><strong>
<font face="Tahoma" size="2">Baths Rooms</font></strong></td>
</tr>
<tr>
<td width="20%">
<input type= "hidden" name="selecttown" value="<?=$selecttown?>">
<input type= "hidden" name="lowprice" value="<?=$lowprice?>">
<input type= "hidden" name="highprice" value="<?=$highprice?>">
<input type= "hidden" name="bedroomsel" value="<?=$bedroomsel?>">
<input type= "hidden" name="bathselect" value="<?=$bathselect?>">
<select size="7" name="selecttown" multiple>
<option value="Acworth NH">Acworth, NH</option>
<option value="Charlestown NH">Charlestown, NH</option>
<option value="Claremont NH" selected>Claremont, NH</option>
<option value="Croydon NH">Croydon, NH</option>
<option value="Langdon NH">Langdon, NH</option>
<option value="Lempster NH">Lempster, NH</option>
<option value="Newport NH">Newport, NH</option>
<option value="Unity NH">Unity, NH</option>
<option value="Woodstock VT">Woodstock, VT</option>
</select></td>
<td width="20%">
Enter your lowest price
$<input type="text" name="lowprice" size="20" value="0">
Enter your highest price
$<input type="text" name="highprice" size="20" value="300000">
</select>
</td>
<td width="20%">
<input type="radio" value="%" name="bedroomsel" checked><font face="Courier">Any<br>
<input type="radio" value="1" name="bedroomsel"">1<br>
<input type="radio" value="2" name="bedroomsel"">2<br>
<input type="radio" value="3" name="bedroomsel"">3</font></td>
<td width="20%">
<input type="radio" value="%" name="bathselect"><font face="Courier">Any<br>
<input type="radio" value="1" name="bathselect" checked>1<br>
<input type="radio" value="2" name="bathselect">2</font></td>
</tr>
</table>
<p align="center"><input type="submit"><input type="reset"></p>
</form>
</td>
</tr>
</table>
</form>
newcode.php
<?
$this_document = $_SERVER['newcode.php'];
$db_addr = 'XXX'; // address of MySQL server.
$db_user = 'XXX'; // Username to access server.
$db_pass = 'XXX'; // Password access server.
$db_name = 'XXX'; // Name of database to connect to.
$connect = @mysql_connect("$db_addr", "$db_user", "$db_pass");
$page = $_GET['page'];
$limit = $_GET['limit'];
if (!($connect)) // If no connect, error and exit().
{
echo("<p>Unable to connect to the database server.</p>");
exit();
}
if (!(@mysql_select_db($db_name))) // If can't connect to database, error and exit().
{
echo("<p>Unable to locate the $db_name database.</p>");
exit();
}
if (!($limit)){
$limit = 10;} // Default results per-page.
if ( !$page or $page < 0 ) { $page = 0; } // Default page value.
$numresults = mysql_query("SELECT town, list_price, bedrooms, baths, rooms, Id ,IF (lister_office_name like 'Century', 1, 0)
AS featured
FROM residential
WHERE town = '$selecttown'
AND list_price BETWEEN '$lowprice' AND '$highprice'
AND bedrooms like '%$bedroomsel'
AND baths like '%$bathselect'
ORDER BY featured DESC, list_price DESC"); // the query.
$numrows = mysql_num_rows($numresults); // Number of rows returned from above query.
if ($numrows == 0){
echo("No results found matching your query"); // modify the "Not Found" error for your needs.
exit();}
$pages = intval($numrows/$limit); // Number of results pages.
// $pages now contains int of pages, unless there is a remainder from division.
if ($numrows % $limit) {
$pages++;} // has remainder so add one page
$current = intval($page/$limit) + 1; // Current page number.
if (($pages < 1)) {
$total = 1;} // If $pages is less than one, total pages is 1.
else {
$total = $pages;} // Else total pages is $pages value.
$first = $page + 1; // The first result.
if (!((($page + $limit) / $limit) >= $pages) && $pages != 1) {
$last = $page + $limit;} //If not last results page, last result equals $page plus $limit.
else{
$last = $numrows;} // If last results page, last result equals total number of results.
//escape from PHP mode.
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" border="0" cellpadding="2">
<!--DWLayoutTable-->
<tr>
<td width="323" align="left"><font size="1" face="Arial, Helvetica, sans-serif">Results
per-page: <a href="<?=$this_document?>?query=<?=$query?>&page=<?=$page?>&limit=5">5</a>
| <a href="<?=$this_document?>?query=<?=$query?>&page=<?=$page?>&limit=10">10</a>
| <a href="<?=$this_document?>?query=<?=$query?>&page=<?=$page?>&limit=20">20</a>
| <a href="<?=$this_document?>?query=<?=$query?>&page=<?=$page?>&limit=50">50</a></font><font face="Arial, Helvetica, sans-serif">
</font></td>
<td colspan="2" align="left"><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
</tr>
<tr>
<td align="left"><font size="2" face="Arial, Helvetica, sans-serif">Showing
Results <b>
<?=$first?>
</b> - <b>
<?=$last?>
</b> of <b>
<?=$numrows?>
</b></font></td>
<td width="324" align="left"><font size="2" face="Arial, Helvetica, sans-serif">Page
<b>
<?=$current?>
</b> of <b>
<?=$total?>
</b></font></td>
<td width="324" align="left"><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"><font size="2" face="Arial, Helvetica, sans-serif"> </font>
<div align="left"><font size="2" face="Arial, Helvetica, sans-serif"></font></div>
<font size="2" face="Arial, Helvetica, sans-serif">
<?
//$limitnum = 15;
if ($page != 0) { // Don't show back link if current page is first page.
$back_page = $page - $limit;
echo("<a href=\"$this_document?query=$query&page=$back_page&limit=$limit\">back</a>\n");}
for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
{
$ppage = $limit*($i - 1);
if ($ppage == $page){
echo("<b>$i</b>\n");} // If current page don't give link, just text.
//elseif ($ppage < $page - $limitnum || $ppage > $page + $limitnum){}
else{
echo("<a href=\"$this_document?query=$query&page=$ppage&limit=$limit\">$i</a>\n");}
}
if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link.
$next_page = $page + $limit;
echo(" <a href=\"$this_document?query=$query&page=$next_page&limit=$limit\">next</a>");}
?>
</font></td>
</tr>
<tr>
<td colspan="3" align="left"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td colspan="3" align="left">
<?
//Go back into PHP mode.
// Now we can display results
$results = mysql_query("SELECT * FROM residential ORDER BY list_price ASC LIMIT $page, $limit");
echo "<TR bgcolor=\"#4f5c38\"><TD align=\"center\"><font color=\"#CCCC66\"><strong>Domain Name</strong></font></TD><TD
align=\"center\"><font color=\"#CCCC66\"><strong>Date Submitted</strong></font></TD><TD align=\"center\"><font
color=\"#CCCC66\"><strong>Asking Price</strong></font></TD></TR>\n";
for($i = 0; $i < $limit; $i++){
for ($count = 1; $row = mysql_fetch_assoc ($results);++$count)
{
if ($count & 1) {
$color = "#9aa486";
$font = "white";
}
else {
$color = "#c8cfc6";
$font = "black";
}
$printthis = "
<tr>
<td bgcolor=$color>
<font color=$font>$row[Id]</font>
</td>
<td bgcolor=$color>
<font color=$font>$row[name]</font>
</td>
<td bgcolor=$color><font color=$font>$row[list_price]</font></td></tr>";
print $printthis;
}
}
?>
</td>
</tr>
</table>
</body>
</html>
Thank you....