facebookappguru Posted March 23, 2010 Share Posted March 23, 2010 ok, finding this pretty hard i have a database of famous birthdays which i bought. its layout is like this : INSERT INTO `birthdays` (`ID`, `birthday`, `Name`) VALUES (1, '1449-01-01', 'Lorenzo de''Medici, (The Magnificent) of Florence'), (2, '1481-01-01', 'Huldrych Zwingli, Swiss Protestant reformer'), (3, '1735-01-01', 'Paul Revere, US patriot and The British are coming'), Problem is, the way i want to search the database is by searching on the date you were born, eg 12th may, so i tried $sql = "SELECT * FROM `birthdays` WHERE `birthday` LIKE \'%05-12%\' LIMIT 0, 10 "; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo 'you share your birthday with ' .$row["name"]. ''; } But then nothing shows, Help please Quote Link to comment https://forums.phpfreaks.com/topic/196218-using-like-help-please/ Share on other sites More sharing options...
fenway Posted March 23, 2010 Share Posted March 23, 2010 Why not use mysql's MONTH() and DAY() functions? Quote Link to comment https://forums.phpfreaks.com/topic/196218-using-like-help-please/#findComment-1030549 Share on other sites More sharing options...
JustLikeIcarus Posted March 25, 2010 Share Posted March 25, 2010 As fenway stated you should be doing something along the lines of SELECT * FROM `birthdays` WHERE month(birthday) = 5 and day(birthday) = 12 LIMIT 0, 10 Quote Link to comment https://forums.phpfreaks.com/topic/196218-using-like-help-please/#findComment-1031404 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.