zura08 Posted October 27, 2008 Share Posted October 27, 2008 i have the problem on sql code. i want to display the data between 1month after the current date.. $sql = "SELECT Kod_siri,Nama_item,Tarikh_luput,Kuantiti FROM stok where Tarikh_luput >='CURDATE()+ INTERVAL 30 DAY ' order by Kod_siri"; is this the correct sql query.. Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/ Share on other sites More sharing options...
DeanWhitehouse Posted October 27, 2008 Share Posted October 27, 2008 I'm not sure but shouldn't it be NOW() instead of CURDATE(), if not you can always do it in PHP Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675513 Share on other sites More sharing options...
MadTechie Posted October 27, 2008 Share Posted October 27, 2008 try this $sql = "SELECT Kod_siri,Nama_item,Tarikh_luput,Kuantiti FROM stok WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) >= Tarikh_luput order by Kod_siri"; Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675514 Share on other sites More sharing options...
zura08 Posted October 27, 2008 Author Share Posted October 27, 2008 i already try the code but data still not appear..the are the data that tarikh luput is between in the month from the current date... Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675535 Share on other sites More sharing options...
MadTechie Posted October 27, 2008 Share Posted October 27, 2008 whats the field type ? verify the sql data Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675569 Share on other sites More sharing options...
zura08 Posted October 27, 2008 Author Share Posted October 27, 2008 <?php print date ('y-m-d',strtotime( $Tarikh_luput))?> the field type is date.is this the right code for me to display the date according to the sql i write it?? Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675647 Share on other sites More sharing options...
DeanWhitehouse Posted October 27, 2008 Share Posted October 27, 2008 Going back to what i said, can you not just do it in php in the while loop? Or $date = date("Do your date format",strtotime("+ 1 month")); WHERE ".$date." >= Tarkih_luput Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675649 Share on other sites More sharing options...
zura08 Posted October 27, 2008 Author Share Posted October 27, 2008 <?php $CURDATE = date("yyyy-mm-dd"); $date = date("yyyy-mm-dd",strtotime("+ 1 month")); $conn=mysql_connect("localhost","root","") or die("TIDAK boleh buat SAMBUNGAN ke MySQL!"); $db=mysql_select_db("zns_inventori",$conn); $sql = "SELECT Kod_siri,Nama_item,Tarikh_luput,Kuantiti FROM stok where DATE_SUB(CURDATE(),INTERVAL 30 DAY) >= Tarikh_luput order by Kod_siri" ; $rs = mysql_query($sql, $conn); $bil_rekod = mysql_num_rows($rs); if ($bil_rekod <= 0) { echo "<center><b>Tiada produk yang menghampiri tarikh luput bulan ini.<b></center>"; //header("location:welcomes.php"); exit(); } else ?> can i do with this sql?? Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675717 Share on other sites More sharing options...
MadTechie Posted October 27, 2008 Share Posted October 27, 2008 Hummm usingstrtotime ? okay what is the field type in the my sql database ? Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675723 Share on other sites More sharing options...
zura08 Posted October 27, 2008 Author Share Posted October 27, 2008 the type in mysql database is date.. Quote Link to comment https://forums.phpfreaks.com/topic/130260-date-problem-to-display-the-data/#findComment-675733 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.