Page 1 of 1

Searching on height function

Posted: Fri May 13, 2005 2:08 am
by wizzard81
Hi,

I have a problem i don't know how to start with a searching on height. I have member profiles on my websites and i want visitors to search on height like > 4ft <6ft.

Anyone an idea how i best can start with this?

Posted: Fri May 13, 2005 2:26 am
by Chris Corbyn
You mean take data from your database only within a given range?

Unsanitized example (Could enter a negative range by accident).

Code: Select all

$start = 4;
$end = 6;

$query = "SELECT * FROM `table` WHERE `height` > $start AND `height` < $end ORDER BY `height`";

$results = mysql_query($query);

Posted: Fri May 13, 2005 3:15 am
by m3mn0n
Be sure to web search for some MySQL data extraction tutorials.

"mysql select tutorial php"

This is a pretty simple procedure and it, like many others that are similar, can be learned very easily through an online tutorial or a book.

Posted: Fri May 13, 2005 12:52 pm
by wizzard81
I mean how do i best store values like 4ft1 5ft1 5ft2 in my database so i can search easy later on the values.

Posted: Fri May 13, 2005 2:21 pm
by Chris Corbyn
Convert them to decimal values before adding to the database and also beofre running queries...

Store them in a FLOAT column type in the database.

It should be easy enough to make the function to convert imperial to decimal and then one to do decimal to imperial (but if you need some help.... :wink: )