Hej herinde!
Er i gang med at lave en hjemmeside, hvor der automatisk vises tekster for de næste 14 dage.
Jer helt ny inden for PHP, og kan ikke lige knække hvordan jeg skal ændre denne kode til at strække sig over de næste 14 dage, i stedet for den aktuelle dag:
case 'by_day':
$query = $select.' DAY(NOW())=DAY(historicdate) '.
' AND MONTH(NOW())=MONTH(historicdate) AND'.$published.$order;
break;
Hvis det kan hjælpe er hele php koden her:
<?php
/**
* Efemerides Model for Efemerides Component
*
* @package Efemerides
* @subpackage Components
* @link http://revolucionemosoaxaca.org
* @license GNU/GPL
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
jimport( 'joomla.application.component.model' );
/**
* Efemerides Model
*
* @package Efemerides
* @subpackage Components
*/
class EfemeridesModelEfemerides extends JModel
{
/**
* Gets the greeting
* @return string The greeting to be displayed to the user
*/
function putFormattedDate($list)
{
jimport( 'joomla.utilities.date' );
$config =& JFactory::getConfig();
$offset = $config->getValue('config.offset' );
foreach ($list as $l)
{
$date = new JDate( $l->thedate, $config->getValue('config.offset' ));
$l->formatteddate = JHTML::_('date', $date->toFormat(), JText::_('DATE_FORMAT_LC'));
$newlist[] = $l;
}
return $newlist;
}
function getEfemerides($date_range)
{
$db =& JFactory::getDBO();
$published = ' published=1';
$select = 'SELECT DAY(historicdate) as theday,MONTH(historicdate) as themonth, YEAR(historicdate) as theyear, historicdate as thedate,title,description'.' FROM #__efemerides WHERE';
$order = ' ORDER BY MONTH(historicdate),DAY(historicdate),YEAR(historicdate)';
$query = ''.$select.$published.$order;
switch($date_range)
{
case 'by_day':
$query = $select.' DAY(NOW())=DAY(historicdate) '.
' AND MONTH(NOW())=MONTH(historicdate) AND'.$published.$order;
break;
case 'by_month':
$query = $select.' MONTH(NOW())=MONTH(historicdate) AND'.$published.$order;
break;
case 'by_year':
$query = ''.$select.$published.$order;
break;
}
$db->setQuery($query);
$db->query();
$efemerides = $db->loadObjectList();
$efemerides = $this->putFormattedDate($efemerides);
//print_r($efemerides);
return $efemerides;
}
}
?>
Jeg vil være meget glad for et svar
Mvh. Christian.
Indlæg senest redigeret d. 05.05.2010 14:27 af Bruger #15875