wanted Posted January 28, 2008 Share Posted January 28, 2008 I tried my best but it still cant solve. I hope u guys can help me. Here i've problem with how to do search in year & month using php & mysql. My problem is i'dont know how to take date ("d/m/Y") m(month) & Y(year) from my database. Format date ("d/m/Y"). Main idea is to display year first followed by month.It have 2 selection list, that is year(2008) & month(Jan-Dec). But i've done year first & still not getting anything.. this is my code <?php mysql_connect ("","","")or die (mysql_error()); mysql_select_db ("") or die (mysql_error()); $receivedDate = date ("d/m/Y"); $split = sprintf('%02d%02d%04d', $d, $m, $Y); $d = $components[1]; $m = $components[2]; $Y = $components[3]; if ($_POST['selectOrder'] = "2008") { $Y =$_POST['selectOrder']; $sql = sprintf ("SELECT * FROM tbl_order WHERE [b]year[/b](receivedDate =) %d", $Y); echo ($sql); { } } ?> <form action="" method="post" name="form1" id="form1"> <p align="center"> <select name="selectOrder" id="selectOrder"> <option selected="selected">- Year -</option> <option value="2008">2008</option> </select><br><br> </p> </form> Quote Link to comment Share on other sites More sharing options...
mem0ri Posted January 28, 2008 Share Posted January 28, 2008 One solution is to store dates as a "timestamp" and then translate them through php before showing them on-screen to users. Doing so allows you the greatest flexibility and allows you to store day, month, year, hour, minute, and second all at once. Quote Link to comment Share on other sites More sharing options...
wanted Posted January 28, 2008 Author Share Posted January 28, 2008 How to do timestamp?? It is a realtime?? I'm just want take data from database & sort with year, which i can take from format date("d/m/Y").. wanna take this Y & sort with it.. Does it have another solution?? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted January 28, 2008 Share Posted January 28, 2008 Simple in PHP: store this. $date=date('Y-m-d H:i:s'); Retrieve this. $date1=date('d-m-Y H:i:s',strtotime($row['date'])); If i am getting you correctly. Quote Link to comment Share on other sites More sharing options...
wanted Posted January 29, 2008 Author Share Posted January 29, 2008 Here my desires output.. [attachment deleted by admin] 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.