lovephp Posted May 23, 2014 Share Posted May 23, 2014 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted May 23, 2014 Share Posted May 23, 2014 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. Quote Link to comment Share on other sites More sharing options...
lovephp Posted May 23, 2014 Author Share Posted May 23, 2014 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; Quote Link to comment Share on other sites More sharing options...
Barand Posted May 23, 2014 Share Posted May 23, 2014 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/>"; } Quote Link to comment Share on other sites More sharing options...
Solution lovephp Posted May 23, 2014 Author Solution Share Posted May 23, 2014 oops i missed that thats alot bro cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.