Jump to content

PHP Search Form


usman07

Recommended Posts

nope, it's in place of the of the html, so:

<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>

  • Replies 93
  • Created
  • Last Reply

not much benefit to replacing the rest of the form items.  That should do it for the index page.  So onto the search results page: form is still using action="insert.php" and method="get".  change the method to method="POST" and then put the following at the top of insert.php

<?php
die(vardump($_POST));
//...rest of your code 

 

post up what you get back and we'll go through it.

Iv done what u said and I get this error

Fatal error: Call to undefined function vardump() in /home/a2221438/public_html/insert.php on line 28

 

I must of done something wrong.

 

Do i place this code at the top of the page or just before my php code?and is there not meant to be a closing php tag.

<?php
die(vardump($_POST));
//...rest of your code 

 

This is some of my insert.php file

<!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>
<title>Mumtaz Properties</title>
	<link 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" alt=""/></a></div>
		</div>

<div id="navigation">
<a id="Home" href="index.php" title="home"><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="results"><img src="cutouts/Homepage/results.png"></div>
<?php
if ($debug) { // a variable I set at script top for debugging ;-)
   echo "<!-- $sql -->";
} 
..............................CONTINUED

Just another thing, I realised the drop down list brings up prices like £50,£60,£70 etc..how would i change it to £50,000 etc


<select name="min price">
	<?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\"$minPrice\">£$minPrice</option>";
  }
}
?>		</select> to

	<select name="max price">
	<?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\"$maxPrice\">£$maxPrice</option>";
  }
}
?>

for the price thing, either just add the relevent no of 0's into the if condition, or, my preffered way would be to add them onto the string:

 echo "<option value\"$minPrice\,000">£$minPrice,000</option>";

(makes it easier to get the , in there)

 

I'm guessing from the var_dump that you didn't change over the Property Type so it was the same as the areas element?

Could the width be set like this?


<select name="min price" 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>";
  }

it words on any tag, I thought that it was the submit button that was falling off.  use it on a select, a table, a div, pretty much anything : <select name="name" style="width:80px;"> || <input type="submit" name="submit" value="Click Me" style="width:80px;" /> || <table border="1" style="width:80px;"> || <ul style="width:80px;">

 

you get the idea ;)

Yeah,thanks for that here is what i'v done for the php code for property_type. i think I have messed it all up tho.

<div id="ptype">
<?php
$propertySql = "SELECT id, area_name FROM property GROUP by type";
$proQry = mysql_query($propertySql) or die (mysql_error());
echo "<select name=\"radio\" multiple=\"multiple\" size\"=5\" style=\"width:150px;\">";
while ($property = mysql_fetch_assoc($proQry)){
echo "<option value=\"{$property['id']}\">{$property['type']}</option>";
}
echo "</select>";
?>
</div>

 

ahh, your using a table....try changing "Number of Bedrooms" to "No. of Bedrooms".

 

I'm off for today, research $_POST and have a look on my blog - ( http://muddy-dev.blogspot.co.uk/ ) there is a section on there that covers simple SQL using JOINS, your going to need to know that for the results page.

you also need to add an = sign to the last echo in this bit of code (compare with your last post of this code), and check the maxPrice one aswell

<select name="min price" 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>";
  }

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.