?yyear= help needed

How do I add 2013 into this string please so that it displays data for both years:

Forthcoming Events

Many thanks if you can help me.

[php]
Forthcoming Events
[/php]

[php]
Forthcoming Events
[/php]

it all depends on what you want to accomplish and im not so sure how you are going to use this link.

I have taken over looking after a website that pulls event data from a database. So when you click on the Forthcoming Events link in the menu bar it currently displays all forthcoming events for 2012. I have added events into the database for 2013 and want them to appear on the Forthcoming Events page under the 2012 events. I hope that makes sense and many thanks for your help!

what data type do you use in your database to store the date?

On the events pages there is the following:

if( !isset($_GET[‘yyear’]) ) {
header(‘Location: ForthcomingEvents.php?yyear=’.date(“Y”));
exit();

How do change this include yyear1 and yyear2?

Many thanks.

And this:

<? $yyear=$yyear; $sql="SELECT * FROM osj_event where yyear='$yyear' order by event_date asc"; $result = mysql_query($sql, $link); while($row = mysql_fetch_object($result)) { list($yr,$mon,$day) = split('-',$row->event_date); ?>

remember you also need:
[php]
Forthcoming Events
[/php]

[php]
if ((!isset($_GET[‘yyear1’]) ) && (!isset($_GET[‘yyear2’]))) {
header(‘Location: ForthcomingEvents.php?yyear=’.date(“Y”));
exit();
[/php]

[php]
$yyear1=$_GET[‘yyear1’];
$yyear2=$_GET[‘yyear2’];

    $sql="SELECT * FROM `osj_event` WHERE `yyear` BETWEEN '$yyear1' AND '$yyear2' ORDER BY `event_date` ASC";

    $result = mysql_query($sql, $link);
    
	while($row = mysql_fetch_object($result))
    {
     list($yr,$mon,$day) = split('-',$row->event_date); 

[/php]

If you don’t mind I would like to propose an alternative. There doesn’t appear to be any need to have a yyear field in your table since you already have event_date

[php]
$years = array(2012, 2013); // this could be url based array ?years[]=2012&years[]=2013
$sql = “SELECT * FROM osj_event WHERE DATE_FORMAT(event_date, ‘%Y’) IN (” . implode(",", $years) . “) ORDER BY event_date ASC”;
[/php]

Perfect - thank you so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service