usman07 Posted April 23, 2012 Author Share Posted April 23, 2012 Thanks for noticing that! I wouldn't have realised. Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1339851 Share on other sites More sharing options...
usman07 Posted April 23, 2012 Author Share Posted April 23, 2012 its missing from the min bedrooms should it have a = sign in the last echo here too? <?php $roomLimit = 5; for($minRooms = 0; $minRooms <= $roomLimit; $minRooms++){ Â if ($minRooms == 0){ Â Â echo"<option value=\"0\" selected=\"selected\">No Min</option>"; Â } Â else{ Â Â echo "<option value\"$minRooms\">$minRooms</option>"; Â } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1339853 Share on other sites More sharing options...
Muddy_Funster Posted April 24, 2012 Share Posted April 24, 2012 yip, echo on both. Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1340060 Share on other sites More sharing options...
usman07 Posted April 25, 2012 Author Share Posted April 25, 2012 What sort of php code do i place in property_type?thanks Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1340453 Share on other sites More sharing options...
usman07 Posted April 28, 2012 Author Share Posted April 28, 2012 Could someone assist me with this PHP form please, would really appreciate it, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341366 Share on other sites More sharing options...
Drummin Posted April 28, 2012 Share Posted April 28, 2012 Just kinda jumping in here. Are you sure you want to use the name="radio" for the property type? echo "<select name=\"radio\" multiple=\"multiple\" size\"=5\" style=\"width:150px;\">"; Seems like you'd use a name more appropriate for this select like "property_type" but I'm not sure what you are looking for when processing the form. Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341369 Share on other sites More sharing options...
usman07 Posted April 28, 2012 Author Share Posted April 28, 2012 Yeah your right thats an error, I need to change that. when processing the form I want to bring up results of properties from the data stored in mysql database. You can check the link here for the website with the search form, to get a better idea. http://mumtazproperties.hostei.com/index.php  Thanks Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341380 Share on other sites More sharing options...
Drummin Posted April 28, 2012 Share Posted April 28, 2012 I don't see where you've add the the search terms for property_type? Not knowing what your table field is called I can only guess. You need to make all your "parts" fit. Form names match processing. Processing matches DB. // grab the search types.    $types = array();    $types[] = isset($_GET['images'])?"`simages` LIKE '%{$searchTermDB}%'":'';    $types[] = isset($_GET['Location'])?"`sLocation` LIKE '%{$searchTermDB}%'":'';    $types[] = isset($_GET['Number of bedrooms'])?"`snumberofbedrooms` LIKE '%{$searchTermDB}%'":'';    $types[] = isset($_GET['property_type'])?"`spropertytype` LIKE '%{$searchTermDB}%'":''; Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341386 Share on other sites More sharing options...
usman07 Posted April 28, 2012 Author Share Posted April 28, 2012 I was wondering in my search form what I wanted was when a user selects 'To Rent' radial button the price min and max will change to per calender month prices, but when 'For Sale' radial button is selected then the min and max price will display the current prices as they do now e.g. 70,000 +. Â How would I do this, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341392 Share on other sites More sharing options...
Drummin Posted April 28, 2012 Share Posted April 28, 2012 Well the only way I can think of is actually submitting the form when a selection is made and then filtering price options by housing type. I don't see where your generating your form but for the radios you'd do something like this. <input type="radio" class="styled" name="ptype" value="forsale" onClick="this.form.submit()" /> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent" onClick="this.form.submit()" /> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any" onClick="this.form.submit()" /> Any </p> Again you'll need to modify the price selection code accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341395 Share on other sites More sharing options...
Drummin Posted April 28, 2012 Share Posted April 28, 2012 Maybe post your current form? Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341400 Share on other sites More sharing options...
usman07 Posted April 28, 2012 Author Share Posted April 28, 2012 My form: <div id="Psearch"><img src="cutouts/Homepage/psearch.png" alt=""/></div> <form action="insert.php" method="POST"> <table id="tb1"> <tr> <td><p class="LOC">Location:</p></td> <td><div id="LC"> <?php $locationSql = "SELECT id, area_name FROM locations GROUP by area_name"; $locQry = mysql_query($locationSql) or die (mysql_error()); echo "<select name=\"areas\" multiple=\"multiple\" size\"=5\" style=\"width:150px;\">"; while ($location = mysql_fetch_assoc($locQry)){ echo "<option value=\"{$location['id']}\">{$location['area_name']}</option>"; } echo "</select>"; ?> </div> </td><td><p class="PT">Property type:</p></td> <td><div id="PS"> <select name="property type" style="width: 170px;"> <option value="none" selected="selected">Any</option> <option value="Houses">Houses</option> <option value="Flats / Apartments">Flats / Apartments</option> </select> </div> </td><td> <div id="ptype"> <input type="radio" class="styled" name="ptype" value="forsale"/> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent"/> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any"/> Any </p> </div> </td> </tr> </table> <div id="table2"> <table id="NBtable"> <tr> <td><p class="NBS">Number of bedrooms:</p></td> <td><div id="NB"> <select name="min bedrooms"> <?php $roomLimit = 5; for($minRooms = 0; $minRooms <= $roomLimit; $minRooms++){  if ($minRooms == 0){   echo"<option value=\"0\" selected=\"selected\">No Min</option>";  }  else{   echo "<option value=\"$minRooms\">$minRooms</option>";  } } ?> </select> to <select name="max bedrooms"> <?php $roomLimit = 5; for($maxRooms = 0; $maxRooms <= $roomLimit; $maxRooms++){  if ($maxRooms == 0){   echo"<option value=\"0\" selected=\"selected\">No Max</option>";  }  else{   echo "<option value=\"$maxRooms\">$maxRooms</option>";  } } ?> </select> </div> </td> <td><p class="PR">Price range:</p></td> <td><div id="PR"> <select name="min price" style='width:80px;'> <?php $priceLimit = 350; for($minPrice = 40; $minPrice <= $priceLimit; $minPrice =( $minPrice+ 10)){  if ($minPrice == 40){   echo"<option value=\"0\" selected=\"selected\">No Min</option>";  }  else{   echo "<option value=\"$minPrice000\">£$minPrice,000</option>";  } } ?> </select> to <select name="max price" style='width:80px;'> <?php $priceLimit = 350; for($maxPrice = 40; $maxPrice <= $priceLimit; $maxPrice =( $maxPrice+ 10)){  if ($maxPrice == 40){   echo"<option value=\"0\" selected=\"selected\">No Max</option>";  }  else{   echo "<option value=\"$maxPrice000\">£$maxPrice,000</option>";  } } ?> </select> </div> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341408 Share on other sites More sharing options...
Drummin Posted April 29, 2012 Share Posted April 29, 2012 As this topic had over 1000 views, I thought I'd go a make a sample page based on what I understand from this post. The DB tables are based on the tables Muddy_Funster suggested with just a few tweeks. The table `properties` is lower-cased and I changed the field `type` to `housing_type`. Although I think bathrooms should be added to the filter, I did not add it to this sample.  This sample posts to the same page, so as items in the form are selected, the form submits and options changed if needed. Submitting the form will show any results above the form.  This sample may take some tweaking to fit your needs but is working with the tables I have. <!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>Mumtaz Properties</title> <link type="text/css" rel="stylesheet" href="cutouts/style.css"/> </head> <body> <!--Main Div Tag--> <div id="wrapper"> <div id="header"> <div id="logo"><a href="index.html"><img src="cutouts/Homepage/logo.png" title="Mumtaz Properties Logo" alt=""/></a></div> </div> <div id="navigation"> <a id="Home" href="index.php" title="homepage"><span>home</span></a> <a id="Sale" href="forsale.html" title="for sale"><span>for sale</span></a> <a id="Rent" href="forrent.html" title="for rent"><span>for rent</span></a> <a id="Contact" href="contact.html" title="contact us"><span>contact us</span></a> </div> <div id="main"> <div id="flashContent"> <center> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="1015" height="465" id="FlashEdited2" align="middle"> <param name="movie" value="Flash Edited2.swf" /> <param name="quality" value="best" /> <param name="bgcolor" value="#ffffff" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="transparent" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="sameDomain" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="Flash%20Edited2.swf" width="1015" height="465"> <param name="movie" value="Flash Edited2.swf" /> <param name="quality" value="best" /> <param name="bgcolor" value="#ffffff" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="transparent" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="sameDomain" /> <!--<![endif]--> <a href="http://www.adobe.com/go/getflash"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /> </a> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </center> </div> <div id="Psearch"><img src="cutouts/Homepage/psearch.png" alt=""/></div> <?php $server = "";   // Enter your MYSQL server name/address between quotes $username = "";  // Your MYSQL username between quotes $password = "";  // Your MYSQL password between quotes $database = "";  // Your MYSQL database between quotes $con = mysql_connect($server, $username, $password);   // Connect to the database if(!$con) { die('Could not connect: ' . mysql_error()); } // If connection failed, stop and display error mysql_select_db($database, $con); // Select database to use // Query database // If there are no errors, lets get the search going. if (isset($_POST['search'])) { $searchSQL = "SELECT p.id, p.location_id, p.catagory_id, p.housing_type, p.bedrooms, p.bathrooms, p.receptions, p.parking, p.garden, p.market_type, p.asking_price, p.pay_interval, p.summary, p.full_description, i.image_path, l.area_name "; $searchSQL .= "FROM properties AS p "; $searchSQL .= " LEFT JOIN images AS i "; $searchSQL .= "ON "; $searchSQL .= "i.property_id = 'p.id'"; $searchSQL .= " LEFT JOIN locations AS l "; $searchSQL .= "ON "; $searchSQL .= "l.area_name = 'p.location_id'"; $searchSQL .= " WHERE "; $types = array(); $ltypes = array(); if (isset($_POST['property_type']) && $_POST['property_type']!="none"){ $property_type = mysql_real_escape_string($_POST['property_type']); $types[] = "p.housing_type ='$property_type'"; } if (isset($_POST['min_bedrooms']) && $_POST['min_bedrooms']>0){ $types[] = "p.bedrooms >= '{$_POST['min_bedrooms']}'"; } if (isset($_POST['max_bedrooms']) && $_POST['max_bedrooms']>0){ $types[] = "p.bedrooms <= '{$_POST['max_bedrooms']}'"; } if ($_POST['min_price']>0){ $min_price = mysql_real_escape_string($_POST['min_price']);  $types[] = "p.asking_price >= '$min_price'"; } if ($_POST['max_price']>0){ $max_price = mysql_real_escape_string($_POST['max_price']); $types[] = "p.asking_price <= '$max_price'"; } //Not sure if "forsale" and "forrent" is listed under the `market_type` field. Change field if needed. if (isset($_POST['ptype'])){ $market_type = mysql_real_escape_string($_POST['ptype']); $types[] = "p.market_type = '$market_type'"; } if (isset($_POST['areas'])){ foreach ($_POST['areas'] as $location_id){ if ($location_id!="none"){ $ltypes[] = "p.location_id = '$location_id'"; } } $locationtypes = implode(" OR ", $ltypes); $types[] .= "($locationtypes)"; } $searchSQL .= implode(" AND ", $types); $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { echo "The search term provided yielded no results."; }else{ $i = 0; echo '<div class="container" style="float:left;">'; while($row = mysql_fetch_array($searchResult)) { $i++; echo '<div class="imageholder" style="float:left;">'; echo '<img class="image1" src="'. $row['image_path'] .'" />'; echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:13px; float:left; padding-top:10px;">'; echo "<span style=\"color:green;\"><b>Displaying record $i<br>\n</b><br></span>"; echo "<b>" . $row['id'] . "</b><br>\n";   echo "Location: ". $row['area_name'] . "<br>\n";      echo "Property Type: ". $row['housing_type'] . "<br>\n";   echo "Bedrooms: ". $row['bedrooms'] . "<br>\n"; echo "Purchase Type: ". $row['market_type'] . "<br>\n";   echo "Price: ". $row['asking_price'] . "<br>\n";    echo '</div>'; echo '<div style="clear:both"></div>'; } echo '</div>'; } } echo '<div style="clear:both"></div>'; ?> <form action="" method="post"> <table id="tb1"> <tr> <td><p class="LOC">Location:</p></td> <td> <div id="LC"> <?php $locationSql = "SELECT id, area_name FROM locations GROUP by area_name"; $locQry = mysql_query($locationSql) or die (mysql_error()); echo "<select name=\"areas[]\" multiple=\"multiple\" size=\"5\" style=\"width:150px;\">"; while ($location = mysql_fetch_assoc($locQry)){ echo "<option value=\"{$location['id']}\"" . (isset($_POST['areas']) && in_array($location['id'],$_POST['areas']) ? 'selected="selected"' : '').">{$location['area_name']}</option>"; } echo "</select>"; ?> </div> </td> <td><p class="PT">Property type:</p></td> <td> <div id="PS"> <?php $property_types= array("none"=>"Any","Houses"=>"Houses","Flats / Apartments"=>"Flats / Apartments"); echo '<select name="property_type" style="width: 170px;" onChange="this.form.submit()">'; foreach ($property_types as $ptype => $ptshow){ echo "<option value=\"$ptype\"" . (isset($_POST['property_type']) && $_POST['property_type']==$ptype ? 'selected="selected"' : '').">$ptshow</option>";} echo '</select>'; ?> </div> </td> <td> <div id="ptype"> <input type="radio" class="styled" name="ptype" value="forsale" onClick="this.form.submit()"<?php echo (isset($_POST['ptype']) && $_POST['ptype']=="forsale" ? ' checked="checked"' : ''); ?> /> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent" onClick="this.form.submit()"<?php echo (isset($_POST['ptype']) && $_POST['ptype']=="forrent" ? ' checked="checked"' : ''); ?> /> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any" onClick="this.form.submit()"<?php echo (isset($_POST['ptype']) && $_POST['ptype']=="any" ? ' checked="checked"' : ''); ?> /> Any </p> </div> </td> </tr> </table> <div id="table2"> <table id="NBtable"> <tr> <td><p class="NBS">Number of bedrooms:</p></td> <td> <div id="NB"> <select name="min_bedrooms" onChange="this.form.submit()"> <?php $roomLimit = 5; foreach(range(0,$roomLimit) as $minRooms){ if ($minRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; }else{ echo "<option value=\"$minRooms\"" . (isset($_POST['min_bedrooms']) && $_POST['min_bedrooms']=="$minRooms" ? ' selected="selected"' : '') . ">$minRooms</option>"; } } ?> </select> to <select name="max_bedrooms" onChange="this.form.submit()"> <?php $roomLimit = 5; foreach(range(0,$roomLimit) as $maxRooms){ if ($maxRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; }else{ echo "<option value=\"$maxRooms\"" . (isset($_POST['max_bedrooms']) && $_POST['max_bedrooms']=="$maxRooms" ? ' selected="selected"' : '') . ">$maxRooms</option>"; } } ?> </select> </div> </td> <td><p class="PR">Price range:</p></td> <?php //Set prices per housing type if (isset($_POST['ptype']) && $_POST['ptype']=="forrent"){ // for rent limits. SET AS NEEDED. $priceLimit = "1450"; $minPrice = "400"; $step = "50"; $factor = ""; }else{ $priceLimit = "350"; $minPrice = "40"; $step = "10"; $factor = ",000"; } ?> <td> <div id="PR"> <select name="min_price" style="width:80px;" onChange="this.form.submit()"> <?php foreach(range($minPrice,$priceLimit,$step) as $price){ echo "<option value=\"$price$factor\"" . (isset($_POST['min_price']) && $_POST['min_price']=="$price$factor" ? ' selected="selected"' : '') . ">£$price$factor</option>"; } ?> </select> to <select name="max_price" style="width:80px;" onChange="this.form.submit()"> <?php //Set $minPrice variable higher that min_price posted $minPrice=(isset($_POST['min_price']) ? "{$_POST['min_price']}" : "$minPrice"); foreach(range($minPrice,$priceLimit,$step) as $price){ echo "<option value=\"$price$factor\"" . (isset($_POST['max_price']) && $_POST['max_price']=="$price$factor" ? ' selected="selected"' : '') . ">£$price$factor</option>"; } ?> </select> </div> </td> </tr> </table> <div id="submit1"><input type="submit" name="search" value="Search Properties" /></div> </div> </form> <table id="tablepos" border="0" cellpadding="5" cellspacing="0" width="600"> <tr> <td align="left" valign="top" width="200"> <div id="line1"><img src="cutouts/Homepage/linetest.png" alt=""/></div> <div id="image1"><a href="map.html"><img src="cutouts/Homepage/image1.png" alt="" title="Find property using a map"/></a></div> </td> <td align="left" valign="top" width="200"> <div id="line2"><img src="cutouts/Homepage/linetest.png" alt=""/></div> <div id="image2"><a href="#"><img src="cutouts/Homepage/image2.png" alt="" title="Propety features"/></a></div> </td> <td align="left" valign="top" width="200"> <div id="line3"><img src="cutouts/Homepage/linetest.png" alt=""/></div> <div id="image3"><a href="http://mumtazproperties.wordpress.com/" target="_blank"><img src="cutouts/Homepage/blog.png" alt="" title="Property guides"/></a></div> </td> </tr> </table> <div id="follow"><img src="cutouts/Homepage/follow.png" alt=""/> <div id="facebook"><a href="http://en-gb.facebook.com/"><img src="cutouts/Homepage/fb.png" alt="Facebook" title="Facebook"/></a></div> <div id="twitter"><a href="http://twitter.com/"><img src="cutouts/Homepage/twitter.png" alt="Twitter" title="Twitter"/></a></div> </div> </div> <div id="footer"> <a id="fHome" href="index.html" title="homepage"><span>homepage</span></a> <a id="fSale" href="forsale.html" title="for sale"><span>for sale</span></a> <a id="fRent" href="forrent.html" title="for rent"><span>for rent</span></a> <a id="fContact" href="contact.html" title="contact us"><span>contact us</span></a> </div> </div> <!-- www.000webhost.com Analytics Code --> <script type="text/javascript" src="http://stats.hosting24.com/count.php"></script> <noscript><a href="http://www.hosting24.com/"><img src="http://stats.hosting24.com/count.php" alt="web hosting" /></a></noscript> <!-- End Of Analytics Code --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341494 Share on other sites More sharing options...
usman07 Posted April 29, 2012 Author Share Posted April 29, 2012 This is my insert.php file code: <?php die(var_dump($_POST)); if ($debug) { // a variable I set at script top for debugging ;-)  echo "<!-- $sql -->"; } $server = "";   // Enter your MYSQL server name/address between quotes $username = "";  // Your MYSQL username between quotes $password = "";  // Your MYSQL password between quotes $database = "";  // Your MYSQL database between quotes $con = mysql_connect($server, $username, $password);   // Connect to the database if(!$con) { die('Could not connect: ' . mysql_error()); } // If connection failed, stop and display error mysql_select_db($database, $con); // Select database to use // Query database $result = mysql_query("SELECT * FROM Properties"); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search'])) {  $searchTerms = trim($_GET['search']);  $searchTerms = strip_tags($searchTerms); // remove any html/javascript.   if (strlen($searchTerms) < 10) {    $error[] = "Search terms must be longer than 10 characters.";  }else {    $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection.  }   // If there are no errors, lets get the search going.  if (count($error) < 1) {    $searchSQL = "SELECT simages, sLocation, sNumberofbedrooms, sdescription FROM Properties WHERE ";       // grab the search types.    $types = array();    $types[] = isset($_GET['images'])?"`simages` LIKE '%{$searchTermDB}%'":'';    $types[] = isset($_GET['Location'])?"`sLocation` LIKE '%{$searchTermDB}%'":'';    $types[] = isset($_GET['Number of bedrooms'])?"`snumberofbedrooms` LIKE '%{$searchTermDB}%'":'';       $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked)       if (count($types) < 1)     $types[] = "`simages` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked         $andOr = isset($_GET['matchall'])?'AND':'OR';    $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `sLocation`"; // order by title.    $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");       if (mysql_num_rows($searchResult) < 1) {     $error[] = "The search term provided {$searchTerms} yielded no results.";    }else {     $results = array(); // the result array     $i = 1;     while ($row = mysql_fetch_assoc($searchResult)) {       $results[] = "{$i}: {$row['sLocation']}<br />{$row['sNumberofbedrooms']}<br />{$row['sbody']}<br /><br />";       $i++;     }    }  } } function removeEmpty($var) {  return (!empty($var)); } if (!$result) {   echo "Error running query:<br>";   trigger_error(mysql_error()); } elseif(!mysql_num_rows($result)) {   // no records found by query.   echo "No records found"; } else {   $i = 0;   echo '<div class="container" style="float:left;">';  while($row = mysql_fetch_array($result)) {  // Loop through results     $i++; echo '<div class="imageholder" style="float:left;">';     echo '<img class="image1" src="'. $row['images'] .'" />'; //image echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:13px; float:left; padding-top:10px;">';     echo "<span style=\"color:green;\"><b>Displaying record $i<br>\n</b><br></span>";     echo "<b>" . $row['id'] . "</b><br>\n";   // Where 'id' is the column/field title in the database     echo "Location: ". $row['Location'] . "<br>\n";      // Where 'location' is the column/field title in the database     echo "Property Type: ". $row['Property_type'] . "<br>\n";   // as above     echo "Bedrooms: ". $row['Number_of_bedrooms'] . "<br>\n"; // ..     echo "Purchase Type: ". $row['Purchase_type'] . "<br>\n";   // ..     echo "Price: ". $row['Price_range'] . "<br>\n";    // .. echo '</div>'; echo '<div style="clear:both"></div>';   } echo '</div>'; } mysql_close($con); // Close the connection to the database after results, not before. ?> Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341548 Share on other sites More sharing options...
Muddy_Funster Posted May 1, 2012 Share Posted May 1, 2012 OK, here's my updated code for you. As I siad in the mail, this should work, but It's uncommented and only tested on empty tables. I have removed your db credentials as I'm now posting this back in a public area, so you will need to edit the mstr_ref.php and put them back in.  I made a psudo-class for handeling the query which as far as I could test it was doing what it should, and I've tried to keep the css intact as best as I could.  This code isn't really "live ready", there are some changes that should be made before the general public are let loose on it, but for the most part it should do what you're looking for.  Let me know how it goes. 18248_.php 18249_.php 18250_.php Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341881 Share on other sites More sharing options...
usman07 Posted May 1, 2012 Author Share Posted May 1, 2012 Thanks so much, Iv just tested it and the entries on the search form for property type: are being entered but are blank, no text is shown. Also when I submit the search, nothing seems to be displayed. Have a try here: http://www.mumtazproperties.hostei.com/ Thanks  Also. the index and insert files when I downloaded them were e.g. 'index.php.xhtml' I took the .xhtml extension of so it is 'index.php' should have I done that, or should I have left it to 'index.php.xhtml'? Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341884 Share on other sites More sharing options...
Muddy_Funster Posted May 1, 2012 Share Posted May 1, 2012 OK, should be fixed now. 18251_.php 18252_.php Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341885 Share on other sites More sharing options...
usman07 Posted May 1, 2012 Author Share Posted May 1, 2012 Ok, the property type is fixed, but when i submit the search, nothing comes up. Is the file meant to have a extension of insert.php? Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341888 Share on other sites More sharing options...
Muddy_Funster Posted May 1, 2012 Share Posted May 1, 2012 ok, tried this with some sample data and it's getting results (except the image, I havn't set that in the database but everything else seems to be coming out ok. 18253_.php Quote Link to comment https://forums.phpfreaks.com/topic/261048-php-search-form/page/4/#findComment-1341896 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.