Jump to content

Recommended Posts

now below code call data from db by 1-31 jan.. how if i want replace this code..calling data for current month? PLS help!

 

 

<?php

$cmonth = date(m);

$cyear = date(y);

$cart = "select * from tbl_cart where pdate between '2013-01-01' and '2013-01-31' and uid = '".$_SESSION['id']."'";

$rscart = $obj->select($cart);

?>

bpr.inc.php

Link to comment
https://forums.phpfreaks.com/topic/274713-how-to-display-data-for-current-month/
Share on other sites

You can get the first and last day of the current month pretty easily using the date() function. Something like:

 

<?php
$first_day = date('Y-m-\0\1'); # force "01" as the day here.
$last_day = date('Y-m-t'); # the "t" is for the number of days in the given month (i.e. always the last day of the month)

$cart = "select * from tbl_cart where pdate between '$first_day' and '$last_day' and uid = '".$_SESSION['id']."'";
?>

 

Hope I didn't overlook anything...

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.