Posted by Poppitypop on 08/14/07 23:26
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
Navigation:
[Reply to this message]
|