nikolas22t
10-11-2005, 01:42 PM
This is the code for a mambo module...
What i want to do is to print all the events that are in the database for a single day and not a random one...
<?php
/*
* @ Today In History - A Today In History Component
* @ Copyright 2003 by Raydian Hood
* @ Website - http://www.webraydian.com/
* @ License - FreeWare
* @ Version - 1.1 Release
* @ This program is distributed with the hope that it will be useful,
* @ but WITHOUT ANY WARRANTY; without even the implied warranty of
* @ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
// Restrict direct access
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// check for global configuration file
if(!file_exists($mosConfig_absolute_path."/administrator/components/com_today_in_history/config.today_in_history.php")) {
// file wasn't found
echo "Today in History Component not found!<br>\n";
// end of program. No config file.
} else {
// global config for ClickBank Component
include($mosConfig_absolute_path."/administrator/components/com_today_in_history/config.today_in_history.php");
$m_date=getdate();
$query1 = "SELECT count(id) as total_events FROM #__tdihistory WHERE published=1 AND day = ".$m_date['mday']." AND month = ".$m_date['mon']."";
$database->setQuery($query1);
$events_array = $database->loadResult();
if($events_array<>0) {
// Get the total number of records
$query=$database->setQuery("SELECT * FROM #__tdihistory as events WHERE published=1 AND day = ".$m_date['mday']." AND month = ".$m_date['mon']."");
$TotalEvents = $database->loadObjectList($query);
echo $database->getErrorMsg();
// start numbers generator
mt_srand((double)microtime()*1000000);
$ecount = mt_rand(0, ($events_array-1));
// fill arrays with all possible events for today
$e = 0;
$TEvents[] = null;
$TYear[] = null;
$Tid[] = null;
foreach($TotalEvents as $event) {
$TEvents[$e] = $event->event;
$TYear[$e] = $event->year;
$Tid[$e] = $event->id;
$e++;
}
// routine to update displays.
$database->setQuery("UPDATE #__tdihistory SET displays=displays+1 WHERE id=".$Tid[$ecount]."");
if (!$database -> query()) echo "<script> alert('" . $database -> getErrorMsg() . "'); window.history.go(-1); </script>\n";
// if override is set
if($TDIH_OVERRIDE_CSS) {
// title font size
$tFontSize=$TDIH_MOD_TITLE_TEXT_SIZE."px";
// title text color
$tTextColor=$TDIH_MOD_TITLE_TEXT_COLOR;
// description text color
$dTextColor=$TDIH_MOD_DESC_TEXT_COLOR;
// description font size
$dFontSize=$TDIH_MOD_DESC_TEXT_SIZE."px";
// setup for table alignment
if($TDIH_ALIGN_TABLE==0) {
$alignIt='Left';
}
elseif ($TDIH_ALIGN_TABLE==1) {
$alignIt='Right';
}
elseif ($TDIH_ALIGN_TABLE==2) {
$alignIt='Center';
}
elseif ($TDIH_ALIGN_TABLE==3) {
$alignIt='Justify';
}
// title alignment
if($TDIH_MOD_TITLE_TEXT_ALIGN==0) {
$tTextAlign='Left';
}
elseif ($TDIH_MOD_TITLE_TEXT_ALIGN==1) {
$tTextAlign='Right';
}
elseif ($TDIH_MOD_TITLE_TEXT_ALIGN==2) {
$tTextAlign='Center';
}
elseif ($TDIH_MOD_TITLE_TEXT_ALIGN==3) {
$tTextAlign='Justify';
}
// title weight
if($TDIH_MOD_TITLE_TEXT_WEIGHT==0) {
$tTextWeight='Normal';
}
elseif ($TDIH_MOD_TITLE_TEXT_WEIGHT==1) {
$tTextWeight='Lighter';
}
elseif ($TDIH_MOD_TITLE_TEXT_WEIGHT==2) {
$tTextWeight='Bold';
}
elseif ($TDIH_MOD_TITLE_TEXT_WEIGHT==3) {
$tTextWeight='Bolder';
}
// setup for title decor
if($TDIH_MOD_TITLE_TEXT_DECOR==0) {
$tDecor='None';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==1) {
$tDecor='Underline';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==2) {
$tDecor='Overline';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==3) {
$tDecor='Line-through';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==4) {
$tDecor='Underline Overline';
}
// -------------------------------------------
// setup for description decor
if($TDIH_MOD_DESC_TEXT_DECOR==0) {
$dDecor='None';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==1) {
$dDecor='Underline';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==2) {
$dDecor='Overline';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==3) {
$dDecor='Line-through';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==4) {
$dDecor='Underline Overline';
}
// description weight
if($TDIH_MOD_DESC_TEXT_WEIGHT==0) {
$dTextWeight='Normal';
}
elseif ($TDIH_MOD_DESC_TEXT_WEIGHT==1) {
$dTextWeight='Lighter';
}
elseif ($TDIH_MOD_DESC_TEXT_WEIGHT==2) {
$dTextWeight='Bold';
}
elseif ($TDIH_MOD_DESC_TEXT_WEIGHT==3) {
$dTextWeight='Bolder';
}
// description alignment
if($TDIH_MOD_DESC_TEXT_ALIGN==0) {
$dTextAlign='Left';
}
elseif ($TDIH_MOD_DESC_TEXT_ALIGN==1) {
$dTextAlign='Right';
}
elseif ($TDIH_MOD_DESC_TEXT_ALIGN==2) {
$dTextAlign='Center';
}
elseif ($TDIH_MOD_DESC_TEXT_ALIGN==3) {
$dTextAlign='Justify';
}
// table width in percent
$TableWidth=$TDIH_WIDTH_TABLE."%";
} // end of override
$day = $m_date['mday'];
$month = $m_date['month'];
//$year = $m_date['year'];
// override css
if($TDIH_OVERRIDE_CSS) {
// print title
print "<div align=$alignIt><table width=\"$TableWidth\"><tr><td style=\" text-align: $tTextAlign;
font-weight: $tTextWeight;
font-size: $tFontSize;
text-decoration: $tDecor;
color: $tTextColor; \">
On $month $day, $TYear[$ecount]
</td></tr>";
// print event
print "<tr><td width=\"$TableWidth\" style=\" text-align: $dTextAlign;
font-weight: $dTextWeight;
font-size: $dFontSize;
text-decoration: $dDecor;
color: $dTextColor;\">
$TEvents[$ecount]
</td></tr></table></div> ";
} else {
// print title
print "<div><table><tr><td>
On $month $day, $TYear[$ecount]
</td></tr>";
// print event
print "<tr><td>
$TEvents[$ecount]
</td></tr></table></div> ";
}
// nothing to display
} else {
echo "<br>There are $events_array events today.<br>";
}
}
?>
Thank you in advance. i wish i was able to solve it my self
What i want to do is to print all the events that are in the database for a single day and not a random one...
<?php
/*
* @ Today In History - A Today In History Component
* @ Copyright 2003 by Raydian Hood
* @ Website - http://www.webraydian.com/
* @ License - FreeWare
* @ Version - 1.1 Release
* @ This program is distributed with the hope that it will be useful,
* @ but WITHOUT ANY WARRANTY; without even the implied warranty of
* @ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
// Restrict direct access
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// check for global configuration file
if(!file_exists($mosConfig_absolute_path."/administrator/components/com_today_in_history/config.today_in_history.php")) {
// file wasn't found
echo "Today in History Component not found!<br>\n";
// end of program. No config file.
} else {
// global config for ClickBank Component
include($mosConfig_absolute_path."/administrator/components/com_today_in_history/config.today_in_history.php");
$m_date=getdate();
$query1 = "SELECT count(id) as total_events FROM #__tdihistory WHERE published=1 AND day = ".$m_date['mday']." AND month = ".$m_date['mon']."";
$database->setQuery($query1);
$events_array = $database->loadResult();
if($events_array<>0) {
// Get the total number of records
$query=$database->setQuery("SELECT * FROM #__tdihistory as events WHERE published=1 AND day = ".$m_date['mday']." AND month = ".$m_date['mon']."");
$TotalEvents = $database->loadObjectList($query);
echo $database->getErrorMsg();
// start numbers generator
mt_srand((double)microtime()*1000000);
$ecount = mt_rand(0, ($events_array-1));
// fill arrays with all possible events for today
$e = 0;
$TEvents[] = null;
$TYear[] = null;
$Tid[] = null;
foreach($TotalEvents as $event) {
$TEvents[$e] = $event->event;
$TYear[$e] = $event->year;
$Tid[$e] = $event->id;
$e++;
}
// routine to update displays.
$database->setQuery("UPDATE #__tdihistory SET displays=displays+1 WHERE id=".$Tid[$ecount]."");
if (!$database -> query()) echo "<script> alert('" . $database -> getErrorMsg() . "'); window.history.go(-1); </script>\n";
// if override is set
if($TDIH_OVERRIDE_CSS) {
// title font size
$tFontSize=$TDIH_MOD_TITLE_TEXT_SIZE."px";
// title text color
$tTextColor=$TDIH_MOD_TITLE_TEXT_COLOR;
// description text color
$dTextColor=$TDIH_MOD_DESC_TEXT_COLOR;
// description font size
$dFontSize=$TDIH_MOD_DESC_TEXT_SIZE."px";
// setup for table alignment
if($TDIH_ALIGN_TABLE==0) {
$alignIt='Left';
}
elseif ($TDIH_ALIGN_TABLE==1) {
$alignIt='Right';
}
elseif ($TDIH_ALIGN_TABLE==2) {
$alignIt='Center';
}
elseif ($TDIH_ALIGN_TABLE==3) {
$alignIt='Justify';
}
// title alignment
if($TDIH_MOD_TITLE_TEXT_ALIGN==0) {
$tTextAlign='Left';
}
elseif ($TDIH_MOD_TITLE_TEXT_ALIGN==1) {
$tTextAlign='Right';
}
elseif ($TDIH_MOD_TITLE_TEXT_ALIGN==2) {
$tTextAlign='Center';
}
elseif ($TDIH_MOD_TITLE_TEXT_ALIGN==3) {
$tTextAlign='Justify';
}
// title weight
if($TDIH_MOD_TITLE_TEXT_WEIGHT==0) {
$tTextWeight='Normal';
}
elseif ($TDIH_MOD_TITLE_TEXT_WEIGHT==1) {
$tTextWeight='Lighter';
}
elseif ($TDIH_MOD_TITLE_TEXT_WEIGHT==2) {
$tTextWeight='Bold';
}
elseif ($TDIH_MOD_TITLE_TEXT_WEIGHT==3) {
$tTextWeight='Bolder';
}
// setup for title decor
if($TDIH_MOD_TITLE_TEXT_DECOR==0) {
$tDecor='None';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==1) {
$tDecor='Underline';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==2) {
$tDecor='Overline';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==3) {
$tDecor='Line-through';
}
elseif ($TDIH_MOD_TITLE_TEXT_DECOR==4) {
$tDecor='Underline Overline';
}
// -------------------------------------------
// setup for description decor
if($TDIH_MOD_DESC_TEXT_DECOR==0) {
$dDecor='None';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==1) {
$dDecor='Underline';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==2) {
$dDecor='Overline';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==3) {
$dDecor='Line-through';
}
elseif ($TDIH_MOD_DESC_TEXT_DECOR==4) {
$dDecor='Underline Overline';
}
// description weight
if($TDIH_MOD_DESC_TEXT_WEIGHT==0) {
$dTextWeight='Normal';
}
elseif ($TDIH_MOD_DESC_TEXT_WEIGHT==1) {
$dTextWeight='Lighter';
}
elseif ($TDIH_MOD_DESC_TEXT_WEIGHT==2) {
$dTextWeight='Bold';
}
elseif ($TDIH_MOD_DESC_TEXT_WEIGHT==3) {
$dTextWeight='Bolder';
}
// description alignment
if($TDIH_MOD_DESC_TEXT_ALIGN==0) {
$dTextAlign='Left';
}
elseif ($TDIH_MOD_DESC_TEXT_ALIGN==1) {
$dTextAlign='Right';
}
elseif ($TDIH_MOD_DESC_TEXT_ALIGN==2) {
$dTextAlign='Center';
}
elseif ($TDIH_MOD_DESC_TEXT_ALIGN==3) {
$dTextAlign='Justify';
}
// table width in percent
$TableWidth=$TDIH_WIDTH_TABLE."%";
} // end of override
$day = $m_date['mday'];
$month = $m_date['month'];
//$year = $m_date['year'];
// override css
if($TDIH_OVERRIDE_CSS) {
// print title
print "<div align=$alignIt><table width=\"$TableWidth\"><tr><td style=\" text-align: $tTextAlign;
font-weight: $tTextWeight;
font-size: $tFontSize;
text-decoration: $tDecor;
color: $tTextColor; \">
On $month $day, $TYear[$ecount]
</td></tr>";
// print event
print "<tr><td width=\"$TableWidth\" style=\" text-align: $dTextAlign;
font-weight: $dTextWeight;
font-size: $dFontSize;
text-decoration: $dDecor;
color: $dTextColor;\">
$TEvents[$ecount]
</td></tr></table></div> ";
} else {
// print title
print "<div><table><tr><td>
On $month $day, $TYear[$ecount]
</td></tr>";
// print event
print "<tr><td>
$TEvents[$ecount]
</td></tr></table></div> ";
}
// nothing to display
} else {
echo "<br>There are $events_array events today.<br>";
}
}
?>
Thank you in advance. i wish i was able to solve it my self