|
Posted by Harrie Verveer on 07/17/07 15:41
Hi,
I would really try to do this using MySQL (with functions like
DATE_INTERVAL) but besides that:
if ($currentmonth = $month AND $month != 00)
I think you want to compare the months ($currentmonth == $month) and not
assign $month to $currentmonth ($currentmonth = $month).
Kind regards,
Harrie Verveer
---
http://www.ibuildings.nl/blog/authors/Harrie-Verveer
up2trouble wrote:
> I'm trying to search my db and display everyone who has a birthday
> that month. I fixed the forever loop and it displaying people without
> a birthdate entered. The problem is it keeps changing the currentmonth
> variable.
>
> 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>";
> }
> }
> }
>
> 0606*** Whitfield [22]
> 0303*** Scanlan [09]
> 1111*** Whitfield [29]
> 0303*** Shive [15]
> 0808*** Keckeisen [22]
> 0505*** sookram [06]
>
[Back to original message]
|