Jump to content

Showing event this month only


pemula

Recommended Posts

My db:

 

CREATE TABLE `tb_event` (

  `id` tinyint(4) NOT NULL auto_increment,

  `t_date` date default NULL,

  `t_event` varchar(75) default NULL,

  `t_place` varchar(75) default NULL,

  `t_content` text,

  PRIMARY KEY  (`id`)

)

 

Records:

1, '2011-01-09', 'event 1', ...

2, '2011-05-12', 'event 2', ...

3, '2011-09-20', 'event 3', ...

 

-------

 

My code here:

 

<?

$now = date("Y-m-d");

...

...

SELECT * FROM tb_acara WHERE t_tanggal >= $now

...

...

?>

 

It will show all records.. :(

I change >= with <= it didn't show anything

 

-------

 

My goal is:

I only want to show the event which in September (month of 9) on record number 3

 

Can you help me please guys??

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/246453-showing-event-this-month-only/
Share on other sites

You are confusing me, you are creating table 'tb_event'

but... you are querying table 'tb_acara'.....

 

Assuming that your query is against table 'tb_event' this what I would do to retrieve September events:

 

$sql = "SELECT * FROM tb_event WHERE MONTH(t_date)=9";

 

 

 

Archived

This topic is now archived and is closed to further replies.

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