Searching on height function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wizzard81
Forum Commoner
Posts: 66
Joined: Wed Jan 15, 2003 6:05 am
Location: Belgium
Contact:

Searching on height function

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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);
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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.
wizzard81
Forum Commoner
Posts: 66
Joined: Wed Jan 15, 2003 6:05 am
Location: Belgium
Contact:

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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: )
Post Reply