Jump to content

Display users birthday?


lovephp
Go to solution Solved by lovephp,

Recommended Posts

friend i store dob as 12/17/1984 in my table now how do i go on geting users birthday if today is 12/16 how could i display only the mm/dd from table?

 

i tried

 

 

$today = date("m-d");
$result = mysql_query("SELECT * FROM members WHERE dob = '".$today."'");

 

but not happening

Link to comment
Share on other sites

if your date is stored as 12/17/2014 why would you expect 12-17 to find a match?

 

try finding those that begin with "12/17"

$today = date("m/d");
$result = mysql_query("SELECT * FROM members WHERE dob LIKE '$today%'");

Dates should be stored in yyyy-mm-dd format in DATE type fields for maximum functionality, you cannot even sort dates like yours correctly.

Link to comment
Share on other sites

not working it only display just one result

 

 

$today = date("m/d");
$res = mysql_query("SELECT * FROM members WHERE dob LIKE '$today%'");
$rw = mysql_fetch_array($res);
echo $rw['dob'];
echo '<br/>';
echo $rw['name'];
echo '<br/>';
echo $today;
Link to comment
Share on other sites

If you only fetch one result then that is all that will be displayed. Use a while loop to loop through the returned records

$today = date("m/d");
$res = mysql_query("SELECT * FROM members WHERE dob LIKE '$today%'");
while ($rw = mysql_fetch_array($res))
{
    echo "{$rw['dob']}<br/>{$rw['name']}<br/>$today<br/><br/>";
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.