djjamiegee Posted February 20, 2009 Share Posted February 20, 2009 hi i am looking for a piece of code so when my form is submitted and sent to my php page, i then want it to remember that information so i can make links to refresh the page and change the order of the results. as i have go it at the moment it all works how i want it to just when u click a link to change the order it forgets the users choices on the form and returns no results. any ideas?? here is my php and html <!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("mysql14.streamline.net","djjamiegee1","sosolid"); //select which database you want to edit mysql_select_db("djjamiegee1"); //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"); switch ($_GET['bedrooms'] ) { case "price_asc": $query = 'SELECT * FROM properties WHERE $type bedrooms >= $bedrooms AND $maxprice area LIKE $area ORDER BY maxprice ASC'; break; case "price_desc": $query = 'SELECT * FROM from properties WHERE $type bedrooms >= $bedrooms AND $maxprice area LIKE $area ORDER BY maxprice DESC'; break; case "bedrooms_asc": $query = 'SELECT * FROM from properties WHERE $type bedrooms >= $bedrooms AND $maxprice area LIKE $area ORDER BY bedrooms ASC'; break; case "bedrooms_desc": $query = 'SELECT * FROM from properties WHERE $type bedrooms >= $bedrooms AND $maxprice area LIKE $area ORDER BY bedrooms DESC'; } echo '<a href="finderresults.php?sort=price_asc">Click here to sort by price ascending</a><br>'; echo '<a href="?sort=price_desc">Click here to sort by price descending</a><br>'; echo '<a href="finderresultse.php?sort=bedrooms_asc">Click here to sort by bedrooms ascending</a><br>'; echo '<a href="?sort=bedrooms_desc">Click here to sort by bedrooms descending</a><br>'; //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='120' 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='250' colspan='2' align='left'><b>Lease Type:</b> $lease</td>"; echo "</tr>"; echo "<td width='120' 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='250' colspan='2' align='left'><b>Post Code:</b> $postcode</td>"; echo "</tr>"; echo "</table>"; echo "<br>"; }} else { echo "<font size='3'>Sorry no properties were found using your search requirements, Please narrow your prefrences to return more results.</font><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"> <form id="form1" action="finderresults.php" method="get"> <table width="608" border="0" cellpadding="1"> <tr> <td width="109"><legend>Type</legend></td> <td width="100"><legend>Min. Bedrooms</legend></td> <td width="88"><legend>Max. Price</legend></td> <td width="120"><legend>Area [eg. basildon]</legend></td> <td width="153"><legend></legend></td> <td width="12"><legend> </legend></td> </tr> <tr> <td><select name="type" id="select"> <option value="">Any</option> <option value="house">House</option> <option value="flat">Flat</option> <option value="bungalow">Bungalow</option> <option value="mid">Mid Terrace</option> <option value="end">End Terrace</option> <option value="semi">Semi Detached</option> <option value="detached">Detached</option> <option value="cottage">Cottage</option> <option value="other">Other</option> </select></td> <td><select name="bedrooms" id="select"> <option value="1">1 Bedroom</option> <option value="2">2 Bedrooms</option> <option value="3">3 Bedrooms</option> <option value="4">4 Bedrooms</option> <option value="5">5+ Bedrooms</option> </select></td> <td><select name="maxprice" id="select"> <option value="">Any</option> <option value="50000">£50,000</option> <option value="100000">£100,000</option> <option value="150000">£150,000</option> <option value="200000">£200,000</option> <option value="250000">£250,000</option> <option value="300000">£300,000</option> <option value="350000">£350,000</option> <option value="400000">£400,000</option> <option value="450000">£450,000</option> <option value="500000">£500,000 +</option> </select></td> <td><input type="text" name="area" id="label" /></td> <td valign="middle"><input name="submit" type="submit" value="" class="submit"/></td> <td> </td> </tr> </table> </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> many thanks Link to comment https://forums.phpfreaks.com/topic/146151-how-to-remember-form-information/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.