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>

Link to comment
Share on other sites

  • Replies 93
  • Created
  • Last Reply

oh, that amazing! do I need to do the same for all the other fields? replacing the HTML code with the PHP? and would the PHP code be any different? would I just change where it says 'location'.

 

Thanks so much for your continuous help.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Ahhh ok, I get this:

array(6) { ["areas"]=> string(1) "1" ["property_type"]=> string(4) "none" ["min_bedrooms"]=> string(1) "0" ["max_bedrooms"]=> string(1) "0" ["min_price"]=> string(1) "0" ["max_price"]=> string(1) "0" }

Link to comment
Share on other sites

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>";
  }
}
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

For the pricing its not working and Im getting an error

 

This is what iv done:

 

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

 

This is the error:

Parse error: syntax error, unexpected '&' in /home/a2221438/public_html/index.php on line 160

Link to comment
Share on other sites

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>";
  }

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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>";
  }

Link to comment
Share on other sites

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.