Reply to Re: selectbox dynamic range options

Your name:

Reply:


Posted by giloosh on 08/14/07 23:47

On Aug 14, 7:26 pm, Poppitypop <poppity...@gmail.com> wrote:
> Ok, you do this
>
> 1.) you would pull the row with the largest price and the row with the
> smallest price. Ex:
> quarry 1.) SELECT price FROM table ORDER BY price ASC LIMIT 1
>
> quarry 2.) SELECT price FROM table ORDER BY price DESC LIMIT 1
>
> Those will return the highest and lowest prices.
>
> 2.) Subtract the lowest price from the highest price
> $result = $high-$low;
>
> 3.) divide that result by the amount of rages you want
> $num_ranges = 4;
> $range = $result/$num_ranges;
>
> 4.)the ranges are these
> for ($n = 0; $n < $num_ranges; $n++){
> echo $low+($range*$n);
> echo " - ";
> echo $low+($range*($n+1));
>
> }
>
> That should work. I know I didn't write the exact code. Sry

Thank you for your fast reply!
your idea is very clever and would absolutely work.

now this brings another concern. what if the selectbox displays
options that would return 0 results in the search if selected.

if all of the items in the table had prices of $500, $400, $150 and
$100 lets say.
the selectbox would display

100 - 200
200 - 300
300 - 400
400 - 500

if i chose 200 - 300, the query would return 0 results. there are no
items in the table with a price between 200-300.

How would i make this selectbox "smarter" in a way that it would only
display valid options?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация