Solved

Display post from correct month and year

Posted on 2012-04-05
3
446 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 110

Accepted Solution

by:
Ray Paseur earned 500 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 110

Expert Comment

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

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 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