Page 1 of 1

selecting all from database where string contains price...

Posted: Mon Feb 01, 2010 9:42 am
by hairytea
I want to display results based on price being high to low or vice versa...

The string in the database field is always going to be something alog the lines of..."2 night price from £675 per person in a Superior River Wing Room. Flights and tranfsers available on request."!

I want to match the £price section of the string and return results between a given starting and ending number.

Code: Select all

 
$query=" SELECT * FROM  admin_holiday_destinations WHERE holiday_country = '".$show."' AND holiday_type = '".$holType."' AND price  LIKE %£_% BETWEEN ".$startNo." AND ".$endNo." ORDER BY $order  LIMIT $eu, $limit ";
$result=mysqli_query($mysqli, $query);
 
The above is one of my failed attempts.

Any ideas on what I need to do here?

Thank You

N.B.

If the price field holds only numbers such as 345 etc. the script works when using the following statement fine...

Code: Select all

 
$query=" SELECT * FROM  admin_holiday_destinations WHERE holiday_country = '".$show."' AND holiday_type = '".$holType."' AND price BETWEEN ".$startNo." AND ".$endNo." ORDER BY $order  LIMIT $eu, $limit ";
$result=mysqli_query($mysqli, $query);
 

Re: selecting all from database where string contains price...

Posted: Mon Feb 01, 2010 4:10 pm
by social_experiment

Code: Select all

<?php
$query=" SELECT * FROM  admin_holiday_destinations WHERE holiday_country = '".$show."' AND holiday_type = '".$holType."' AND price  LIKE %£_% BETWEEN ".$startNo." AND ".$endNo." ORDER BY $order  LIMIT $eu, $limit ";
$result=mysqli_query($mysqli, $query);
 
while ($resultArray = mysql_fetch_array($result)) {
 echo "£".$resultArray['price'];
}
?>
What if you used the values with the £ sign, and just added it into the query like above?