This is a discussion on date matching for b-days within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I'm trying to query my db for all the birthdays in a month and to return that info to ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm trying to query my db for all the birthdays in a month and to
return that info to my page. It's changing my currentmonth to match the stored month and displaying all records with a birthday. function displayBirthdays($connect, $db_table4) { $currentmonth = date("m"); $currentday = date("d"); $sql = "SELECT dob, lastName, firstName FROM $db_table4"; $result = mysql_query ($sql, $connect) or die ('Query failed: ' .mysql_error()); while ($row = mysql_fetch_array($result)) { $lastname = $row["lastName"]; $firstname = "***"; $dob = $row['dob']; $month = substr($dob,0,2); $day = substr($dob,3,2); if ($currentmonth = $month AND $month != 00) { echo "$month "; echo "$currentmonth "; echo"$firstname $lastname [$day]<BR>"; } } } Result: 6 06 *** Whitfield [22] 03 03 *** Scanlan [09] 11 11 *** Whitfield [29] 03 03 *** Shive [15] 08 08 *** Keckeisen [22] 05 05 *** Sookram [06] |
|
|||
|
On Jul 17, 4:20 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
> 1. Don't multipost. > 2. Answered twice in comp.lang.php > > -- > Rik Wasmus I didn't mean to. For some reason I was unable to post in groups. Kept getting errors. I wasn't sure what went thru. |