Jump to content


Photo

Search by min. and max price


  • Please log in to reply
1 reply to this topic

#1 ivalea

ivalea
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 09 March 2006 - 07:20 AM

Hi!

I am trying to build a search form (am still pretty new to PHP and MySQL so please bear with me) that searches by min and max price by dropdown - like on a real estate site. Right now it's written so that if there are any listings in the database then it takes those prices and puts them in the dropdown. Otherwise if there are no listings then the dropdown shows no options. My code is this:

$MinPrice = "<select name=min>\n\t<option value=\"\">Minimum</option>\n\t";

$q1 = "select distinct Price from re2_listings order by Price asc";
$r1 = mysql_query($q1) or die(mysql_error());

if(mysql_num_rows($r1) > '0')
{
while($a1 = mysql_fetch_array($r1))
{
$prices .= "<option value=\"$a1[Price]\">$ $a1[Price]</option>\n\t";
}
}

$MinPrice .= $prices."</select>\n";


//set the max price menu
$MaxPrice = "<select name=max>\n\t<option value=\"\">Maximum</option>\n\t";
$MaxPrice .= $prices."</select>\n";


Then all I do is reference <?=$MinPrice?> and <?=$MaxPrice?> in the html form where the select should be.

I need the dropdown to display price values in increments of $50,000 starting at $150,000 and ending at $1,000,000+.

I tried inserting a select field in the form the way it normally would be and then setting id's to MinPrice and MaxPrice but that didn't work.

Sorry to be soooo long winded but I've been at this for what seems forever and I so need help! :)
Any thoughts at all as to how I can accomplish this would be sooo greatly appreciated!

Thanks! - Irene

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 March 2006 - 07:30 AM




An example of the way i done the select box thats all good luck.

1 to 1099 pound

In drop down box
$a=$_POST['a']; // box1
$b=$_POST['b'];// box2
$c=$_POST['c'];//box3
$d=$_POST['d'];//box4
$price=('£'.$a.'.'.$b.$c);

<td>Price</td>
<td>
<SELECT NAME="a">
<OPTION VALUE="0">0</option>
<OPTION VALUE="1">£1</option>
<OPTION VALUE="2">£2</option>
<OPTION VALUE="3">£3</option>
<OPTION VALUE="4">£4</option>
<OPTION VALUE="5">£5</option>
<OPTION VALUE="6">£6</option>
<OPTION VALUE="7">£7</option>
<OPTION VALUE="8">£8</option>
<OPTION VALUE="9">£9</option>
<OPTION VALUE="10">£10</option>
<OPTION VALUE="20">£20</option>
<OPTION VALUE="30">£30</option>
<OPTION VALUE="40">£40</option>
<OPTION VALUE="50">£50</option>
<OPTION VALUE="60">£60</option>
<OPTION VALUE="70">£70</option>
<OPTION VALUE="80">£80</option>
<OPTION VALUE="90">£90</option>
<OPTION VALUE="100">£100</option>
<OPTION VALUE="200">£200</option>
<OPTION VALUE="300">£300</option>
<OPTION VALUE="400">£400</option>
<OPTION VALUE="500">£500</option>
<OPTION VALUE="600">£600</option>
<OPTION VALUE="700">£700</option>
<OPTION VALUE="800">£800</option>
<OPTION VALUE="900">£900</option>
<OPTION VALUE="1000">£1000</option>



</SELECT>
<SELECT NAME="b">
<OPTION VALUE="0">0</option>
<OPTION VALUE="1">1</option>
<OPTION VALUE="2">2</option>
<OPTION VALUE="3">3</option>
<OPTION VALUE="4">4</option>
<OPTION VALUE="5">5</option>
<OPTION VALUE="6">6</option>
<OPTION VALUE="7">7</option>
<OPTION VALUE="8">8</option>
<OPTION VALUE="9">9</option>
<OPTION VALUE="10">10</option>
</SELECT>

<SELECT NAME="c">
<OPTION VALUE="0">0</option>
<OPTION VALUE="1">1</option>
<OPTION VALUE="2">2</option>
<OPTION VALUE="3">3</option>
<OPTION VALUE="4">4</option>
<OPTION VALUE="5">5</option>
<OPTION VALUE="6">6</option>
<OPTION VALUE="7">7</option>
<OPTION VALUE="8">8</option>
<OPTION VALUE="9">9</option>
<OPTION VALUE="10">10</option>
</SELECT>



Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users