?
Solved

Display post from correct month and year

Posted on 2012-04-05
3
Medium Priority
?
456 Views
Last Modified: 2012-04-05
I have a blog where you can select to view post from a particular year and month. When you click on the date in the archive list the URL sends the variables over like this...

archive.php?month=March&year=2012

I'm just not sure how to display them on the results page?

The date is stored in the database in date format in the eventdate column.

I basically need a query that says...

Show posts from latestnews where the year and month match those in the eventdate column of the databse.
Screen-shot-2012-04-05-at-14.13..png
Screen-shot-2012-04-05-at-16.35..png
0
Comment
Question by:BrighteyesDesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 37812537
The month and year will arrive in $_GET.  This will create a date range that runs from the first of the month to the end of the month.  Then you just use that in your WHERE clause.

See: http://www.laprbass.com/RAY_temp_brighteyesdesign.php?month=March&year=2012
<?php // RAY_temp_brighteyesdesign.php
error_reporting(E_ALL);

date_default_timezone_set('America/Chicago');

$alpha = date('c', strtotime($_GET["month"] . ' 1, ' . $_GET["year"]));
$omega = date('c', strtotime($_GET["month"] . ' ' . date('t', strtotime($alpha)) . ', ' . $_GET["year"]));
$where = " WHERE eventdate BETWEEN '$alpha' AND '$omega' ";
var_dump($where);

Open in new window

0
 

Author Closing Comment

by:BrighteyesDesign
ID: 37812672
Perfect, thanks for that
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37812710
'nada ;-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question