new_php85 Posted November 4, 2008 Share Posted November 4, 2008 hai... i have problem to select current month... this is my example coding for select current month. why its not appear. $current_month = date(Y-m); $query_cm = "SELECT * FROM cldr WHERE startDate like '$current_month-%' order by startDate desc"; $result_cm = mysql_query($query_cm) or die('Query failed. ' . mysql_error()); <form name="current_month" id="current_month" method = "post"> <table bordercolor="#EEF8D6" border="1" cellpadding="3" cellspacing="0" align="center"> <th width="14"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">No.</font></th> <th width="105"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Name</font></th> <th width="329"><div align="left"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Location</font></div></th> <th width="40"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Start Date</font></th> <th width="40"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">End Date</font></th> <th width="40"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Edit</font></th> <th width="46"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Delete</font></th> <?php $c=1; while($row = mysql_fetch_assoc($result_cm)) { ?> <tr> <td><div align="center"><?php echo $c?></div> <td><?php echo $row['staffKcc']?></td> <td><?php echo $row['location']?></td> <td><?php echo $row['startDate']?></td> <td><?php echo $row['endDate']?></td> <td><div align="center"><a href="editEvent.php?id=<?php echo $row['id']?>">Edit</a></div></td> <td><div align="center"><a href="deleteEvent.php?id=<?php echo $row['id']?>">Delete</a></div></td> </tr> <?php $c++; } ?> </table> </form> plz help me... Quote Link to comment https://forums.phpfreaks.com/topic/131292-solved-how-to-select-current-month/ Share on other sites More sharing options...
MikeDXUNL Posted November 4, 2008 Share Posted November 4, 2008 $query_cm = "SELECT * FROM cldr WHERE startDate like '$current_month-%' order by startDate desc"; what do the startDate values look like in your database? right now $current_month = 2008-11 Quote Link to comment https://forums.phpfreaks.com/topic/131292-solved-how-to-select-current-month/#findComment-681769 Share on other sites More sharing options...
corbin Posted November 4, 2008 Share Posted November 4, 2008 $current_month = date(Y-m); should be $current_month = date("Y-m"); Y-m isn't a constant, so it should be in quotes. What is the datatype of startDate? Quote Link to comment https://forums.phpfreaks.com/topic/131292-solved-how-to-select-current-month/#findComment-681786 Share on other sites More sharing options...
new_php85 Posted November 4, 2008 Author Share Posted November 4, 2008 $query_cm = "SELECT * FROM cldr WHERE startDate like '$current_month-%' order by startDate desc"; what do the startDate values look like in your database? right now $current_month = 2008-11 example in database: startDate = '2008-11-04' i know if i put date(Y-m) it will be 2008-11 that's why in query i put % for day to neglect the value... is it wrong?? Quote Link to comment https://forums.phpfreaks.com/topic/131292-solved-how-to-select-current-month/#findComment-681855 Share on other sites More sharing options...
new_php85 Posted November 4, 2008 Author Share Posted November 4, 2008 $current_month = date(Y-m); should be $current_month = date("Y-m"); Y-m isn't a constant, so it should be in quotes. What is the datatype of startDate? datatype of startDate is date Quote Link to comment https://forums.phpfreaks.com/topic/131292-solved-how-to-select-current-month/#findComment-681856 Share on other sites More sharing options...
new_php85 Posted November 5, 2008 Author Share Posted November 5, 2008 corbin i got what u said. it should like this $current_month = date("Y-m"); thank you ya... $current_month = date(Y-m); should be $current_month = date("Y-m"); Y-m isn't a constant, so it should be in quotes. What is the datatype of startDate? Quote Link to comment https://forums.phpfreaks.com/topic/131292-solved-how-to-select-current-month/#findComment-682592 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.