Jump to content

Recommended Posts

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...

 

Link to comment
https://forums.phpfreaks.com/topic/131292-solved-how-to-select-current-month/
Share on other sites

$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??

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.