/    Sign up×
Community /Pin to ProfileBookmark

Month & Day Are Seen As The Same

Hi all,

I am working on this php file, and have got it to show me members when I select January, it shows me all the birthdays from January but also extra dayes for e.g. it will add 12/01/1980 BUT also 01/12/1980 becuase it has a 1 and January is equal to 1 in my code, so how can I get it to know what is month?

[code=php]
//assign the bday variable.
$month = $_REQUEST[‘month’];

//birthday search
$info = mysql_query(“SELECT * FROM `tblmembers` WHERE `DateOfBirth` LIKE ‘%$month%'”);

echo ‘<table border=”1″ cellpadding=”3″ cellspacing=”1″>
<tr valign=”top”>
<td>First Name</td>
<td>Last Name</td>
<td>DateOfBirth</td>
<td>Last Login</td>
</tr>’;

if (mysql_num_rows($info) < 1) {
echo ‘<tr valign=”top”>
<td colspan=”4″>There are no members that match the query. Please go back and try again</td>
</tr>’;
}

else {
while ($qry = mysql_fetch_array($info)) {

//create the layout
?>
<link href=”cs_style.css” rel=”stylesheet” type=”text/css” />

<tr valign=”top”>
<td><?php echo $qry[‘FirstName’]; ?></td>
<td><?php echo $qry[‘LastName’]; ?></td>
<td><?php echo date(‘d/m/Y’, strtotime($qry[‘DateOfBirth’])); ?></td>
<td><?php echo($qry[‘loginDateTime’]?date(‘d/m/Y H:i:s’, strtotime($qry[‘loginDateTime’])):’N/A’) ?></td>
</tr>
<?php
}
}

echo ‘</table>’;
?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@sitehatcheryMar 15.2007 — $info = mysql_query("select * from tblmembers where month(DateOfbirth) like '%$month%'" );

Edit - Maybe this would be better:

$info = mysql_query("select * from tblmembers where month(DateOfbirth) = '{$month}'" );
Copy linkTweet thisAlerts:
@NightShift58Mar 15.2007 — Or just:[code=php]$info = mysql_query("select * from tblmembers where month(DateOfbirth) = $month" );[/code]
×

Success!

Help @tomyknoker spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...