Jump to content

Recommended Posts

hi

 

i have looked everywhere and i mean everywhere on the web for help to this solution but cant find one that works anywhere.

 

i have a form with 3 drop down boxes and and input fields the user selects from the 3 boxes and then writes in the input field to search my database. this all works fine with the results being displayed by asending by maxprice.

 

i now want a few links at the top of the page so they can chnage the order of how the results are displayed i.e price asc/desc or no. of bedrooms asc/desc i have tried some methods but the main problem i am having is when i click a link at the top it refreshes the page and forgets what the user selected from the form so it then returns no results.

 

any help on this matter will be deeply appreciated. here is my code which is all on the php page with the form at the bottom.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Price Property Services | Search Results</title>
<link rel="stylesheet" type="text/css" href="pps.css" />

</head>

<body id="background">
<div id="maincontainer">
  <div id="mainheader">
    <div id="logo">
      <table width="780" border="0" class="table">
        <tr>
          <td width="182"><img src="logo.gif" width="182" height="92" /></td>
          <td width="588" align="right"><img src="mainbanner.jpg" width="588" height="92" /></td>
        </tr>
      </table>
    </div>
    <div id="nav">
      <ul id="nav">
        <li id="thome"><a href="index.html" class="selected"></a></li>
        <li id="tprop"><a href="properties.html"></a></li>
        <li id="tabout"><a href="about.html"></a></li>
        <li id="tlegal"><a href="legal.html"></a></li>
        <li id="tfees"><a href="fees.html"></a></li>
        <li id="tterms"><a href="terms.html"></a></li>
        <li id="tcontact"><a href="contact.html"></a></li>
        <li id="tlinks"><a href="links.html"></a></li>
      </ul>
    </div>
  </div>
  <div id="mainbodysearch">
    <?php

$type=($_GET['type']=="") ? "" : "type = '{$_GET['type']}' AND";
$bedrooms=$_GET['bedrooms'];
$maxprice= ($_GET['maxprice']=="") ? "" : "maxprice < '{$_GET['maxprice']}' AND";
$area=$_GET['area'];

//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("******","********","*****"); 

//select which database you want to edit
mysql_select_db("*****"); 

//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search 
$result = mysql_query("SELECT * from properties WHERE $type bedrooms >= '$bedrooms' AND $maxprice area LIKE '$area' ORDER BY maxprice");

//how many properties found
$number=mysql_num_rows($result);
echo "$number properties found"; 
echo "<br><br>";	

if (mysql_num_rows($result) > 0) {
//grab all the content
while($r=mysql_fetch_array($result))
{	
   $type=$r["type"];
   $bedrooms=$r["bedrooms"];
   $maxprice=$r["maxprice"];
   $area=$r["area"];
   $first_address=$r["first_address"];
   $link=$r["link"];
   $image=$r["image"];
   $postcode=$r["postcode"];
   $lease=$r["lease"];
   $desc=$r["desc"];
  
  //display the row

echo "<table border='0' cellpadding='5' align='center' width='650' class='search'>";
echo "<tr>";
echo "<td width='100'><img src=\"" . $r["image"] .  "\"></td>";
echo "<td colspan='5' valign='top'>$desc</td>";
echo "<td align='right'><a href=\"" . $r["link"] . "\"><img src=\"info.png" . "\" border=0 alt=\"" . "\"></a></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100' rowspan='2' align='center'><font size='3'><b>£$maxprice</b></font></td>";
echo "<td width='130' colspan='2' align='left'><b>No of Bedrooms:</b> $bedrooms</td>";
echo "<td width='130' colspan='2' align='left'><b>Location:</b> $area</td>";
echo "<td width='240' colspan='2' align='left'><b>Lease Type:</b> $lease</td>";
echo "</tr>";
echo "<td width='130' colspan='2' align='left'><b>Property Type:</b> $type</td>";
echo "<td width='130' colspan='2' align='left'><b>Street:</b> $first_address</td>";
echo "<td width='240' colspan='2' align='left'><b>Post Code:</b> $postcode</td>";
echo "</tr>";
echo "</table>";
echo "<br>";
}}

else {
echo "Sorry no properties were found using your search requirements, Please narrow your prefrences to return more results.<br><br>";
}

?>
  </div>
  <div id="searchbox">
    <div id="searchbox1"><img src="sellingnav.jpg" width="120" height="200" /></div>
    <div id="searchbox1"><img src="buyingnav.jpg" width="120" height="200" /></div>
  </div>
  <div id="mainbodysearch1">
    <div id="finder"><?php
     echo "<form id='form1' action='finderresults.php' method='get'>";
       echo " <table width='608' border='0' cellpadding='1'>";
        echo " <tr>";
         echo " <td width='109'><legend>Type</legend></td>";
            echo "<td width='100'><legend>Min. Bedrooms</legend></td>";
            echo "<td width='88'><legend>Max. Price</legend></td>";
            echo "<td width='120'><legend>Area [eg. basildon]</legend></td>";
            echo "<td width='153'><legend></legend></td>";
            echo "<td width='12'><legend> </legend></td>";
          echo "</tr>";
          echo "<tr>";
            echo "<td><select name='type' id='select'>";
             echo " <option value=''>Any</option>";
             echo " <option value='house'>House</option>";
             echo " <option value='flat'>Flat</option>";
             echo " <option value='bungalow'>Bungalow</option>";
             echo " <option value='mid'>Mid Terrace</option>";
            echo "  <option value='end'>End Terrace</option>";
             echo " <option value='semi'>Semi Detached</option>";
            echo "  <option value='detached'>Detached</option>";
             echo " <option value='cottage'>Cottage</option>";
            echo "  <option value='other'>Other</option>";
          echo "  </select></td>";
          echo "  <td><select name='bedrooms' id='select' value=' . $bedrooms . '>";
           echo "   <option value='1'>1 Bedroom</option>";
           echo "   <option value='2'>2 Bedrooms</option>";
             echo " <option value='3'>3 Bedrooms</option>";
            echo "  <option value='4'>4 Bedrooms</option>";
            echo "  <option value='5'>5+ Bedrooms</option>";
           echo " </select></td>";
           echo " <td><select name='maxprice' id='select'>";
             echo " <option value=''>Any</option>";
             echo " <option value='50000'>£50,000</option>";
            echo "  <option value='100000'>£100,000</option>";
            echo "  <option value='150000'>£150,000</option>";
             echo " <option value='200000'>£200,000</option>";
            echo "  <option value='250000'>£250,000</option>";
             echo " <option value='300000'>£300,000</option>";
             echo " <option value='350000'>£350,000</option>";
            echo "  <option value='400000'>£400,000</option>";
             echo " <option value='450000'>£450,000</option>";
             echo " <option value='500000'>£500,000 +</option>";
           echo " </select></td>";
          echo "  <td><input type='text' name='area' id='label' /></td>";
           echo " <td valign='middle'><input name='submit' type='submit' value='' class='submit'/></td>";
          echo "  <td> </td>";
         echo " </tr>";
       echo " </table>";
     echo " </form>";
 ?>
    </div>
  </div>
  <div id="footer"><a href="">Property Updates</a>  | <a href="">HIP's</a>  | <a href="">Recruitment</a>  | <a href="">Privacy Policy</a>  | <a href="">Site Map</a></div>
</div>
</body>
</html>

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.