Example: $from = 30 and $to = 33. Now I want to get total price between $from and $to.
Here is my code.
$from = $_POST['from'];
$to = $_POST['to'];
$result = mysql_query("SELECT SUM(price) as totalPrice FROM price WHERE price BETWEEN '$from' and '$to'");
$row = mysql_fetch_assoc($result);
$sum = $row['totalPrice'];
SELECT sum(`price`) as total FROM `table` where from = 30 AND `to` = 33
..MAYBE CHANGE AND TO OR, DEPENDING ON WHAT YOU WANT.
SELECT price as total FROM yourtable WHERE from = 30 AND to = 33