|
Posted by gagal on 07/17/07 20:09
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]
Navigation:
[Reply to this message]
|