You are here: Re: I need a genius for this one! « PHP Programming Language « IT news, forums, messages
Re: I need a genius for this one!

Posted by Surfer! on 11/27/54 11:58

In message <1158561685.666825.252900@h48g2000cwc.googlegroups.com>,
ameshkin <amir.meshkin@gmail.com> writes
>What I am trying to do, is...
>
>Find users in a database between two ages.
>
>$minage
>$maxage
>
>The birthdays of the users are in the database in this format
>01-30-1980
>
>Now this function takes a birthday in this format 1980-01-30 and
>returns the age
>
> function birthday ($birthday)
> {
> list($year,$month,$day) = explode("-",$birthday);
> $year_diff = date("Y") - $year;
> $month_diff = date("m") - $month;
> $day_diff = date("d") - $day;
> if ($month_diff < 0) $year_diff--;
> elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
> return $year_diff;
> }
>
>But what I need to do, is somehow only show the results from the
>database where the birthday is in between two different ages.
>
>How do I do this. My brain hurts enough already from writing the
>function above. Can anyone help?
>
Do it in the SQL you use to select from the database. Of course this
assumes you have used a date-type column to hold the date of birth!

For MySQL see:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

Check the YEAR function.



--
Surfer!
Email to: ramwater at uk2 dot net

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация