Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Seeking applications ...
Author Message
andrej
Hangin' Around


Joined: Sep 10, 2005
Posts: 48

PostPosted: Thu Jan 25, 2007 11:56 am Reply with quote

Hello !

I have used a javascript calendar. On my page i used a modified JavaScript Calander, which showed all events in the coming 7 days. A screenshot can be seen here.. Only registered users can see links on this board! Get registered or login!

Now i would like to have same kind of weekly preview as a block on the home page of phpnuke.
The problem is i don't know much coding. I have managed to modify an event list blok, which i got when downloading kalander mx.

the relavant part of it looks like this ..


Code:
while ($a < 7) {

   
   $compare  = date("d.m.y", mktime(0, 0, 0, date("m")  , date("d")+$a, date("y")));
   $pisi = date("d", mktime(0, 0, 0, date("m")  , date("d")+$a, date("Y")));
         $content.="<tr style=\"background-color: $bgcolornew;\">
      <td valign=\"top\" width=\"15%\">$pisi</td>\n<td width=\"85 %\">";
   while(list($eid, $title, $hometext, $posteddate, $topic, $informant, $y1, $m1, $d1, $h1, $mi1, $y2, $m2, $d2, $h2, $mi2, $alldayevent, $categorie) = sql_fetch_row($result, $dbi)) {
      $title = htmlspecialchars(strip_tags(stripslashes($title)), ENT_QUOTES);
      $fontstyle = ($listStarttime) ? "tiny" : "content";
      $dateStart = strftime(_CALSHORTDATEFORMAT, @mktime(0, 0, 0, $m1, $d1, $y1));
      if ($listStarttime && !$alldayevent) {
         $dateStart.= " ".strftime(_CALTIMEFORMAT, @mktime($h1, $mi1, 0, $m1, $d1, $y1));
         }
      if ($dateStart == $compare) {   
      $dateEnd = ($listEnddate) ? strftime(_CALSHORTDATEFORMAT, @mktime(0, 0, 0, $m2, $d2, $y2)) : "";
      if ($listEndtime && !$alldayevent) {
         $dateEnd.= " ".strftime(_CALTIMEFORMAT, @mktime($h2, $mi2, 0, $m2, $d2, $y2));
         }
      $bgcolornew = ($i==0) ? $listbgcolor1 : $listbgcolor2;
      $txtcolornew = ($i==0) ? $listtxtcolor1 : $listtxtcolor2;
      $i = ($i==0) ? 1 : 0;
      $alttext = ($hometext && !$scrolling) ? substr(htmlentities(strip_tags(stripslashes($hometext))),0,70).'...' : "";}

      if ($dateStart == $compare) {   
      $content.="<img src=\"".calGetBarImage("ball",$categorie)."\" $imgprops><span style=\"color: $txtcolornew;\" class=\"tiny\">
      <a href=\"".CAL_MODULE_LINK."&amp;op=view&amp;eid=$eid\" style=\"text-decoration: none;\">$title</a></span><br>\n"; }

      }      
   $content.="</td>\n</tr>\n";   
   $a = $a+1;

}
      $content.= "</table>";


My problem is : The script works ok, if there is no "while ( a< 7 statement ) loop.
If i remove the loop and make $a to be a contant value it works great.. otherwise it doesn't work at all...


p.s. Is it possible that while(list command can be called only once and if it is true, how to replace it efficiently ?
 
View user's profile Send private message
Gremmie
Former Moderator in Good Standing


Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Thu Jan 25, 2007 12:58 pm Reply with quote

Well, what is $a before the loop starts? Is it even set? Did you try putting a $a = 0; before the while?

_________________
Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module 
View user's profile Send private message
andrej
PostPosted: Thu Jan 25, 2007 3:38 pm Reply with quote

yes i did !
It's set to $a=0.
The problem is, it works only for one loop.
The events get displayed on the first loop, but not on the second loop or any further loops, while the day ( function $pisi) is being displayed correctly.
 
andrej
PostPosted: Thu Feb 01, 2007 3:58 pm Reply with quote

The problem is with while function, it refuses to loop.
It only loops once and that's it.
I am not really certian if everything is OK with it (not really sure about the syntax ), so can anyone check it, please ?
 
Gremmie
PostPosted: Thu Feb 01, 2007 7:00 pm Reply with quote

Run the same query in phpMyAdmin and see how many rows you get. Maybe you are only getting 1 row.
 
andrej
PostPosted: Fri Feb 02, 2007 7:48 am Reply with quote

If there are several events on the same day, all of them are displayed. It's just that only events on first day are displayed and no else.
I will just post all the code, maybe something else is wrong..

Since i am not that good it's based on Kalander-mini-list block, so in the begging of the script there some unnecessary variables are defined. I plan to clean them up later, when this starts to work properly.


Code:
<?php

### !!!! don't change this 3 lines !!!! #########################################
$thisfile=basename(__file__);
if (eregi($thisfile, $_SERVER["PHP_SELF"])) die ("You can't access this file directly...");
global $bgcolor1,$bgcolor2,$bgcolor3,$bgcolor4,$bgcolor5,$textcolor1,$textcolor2, $dbi;
#################################################################################

$mxblockcache = FALSE;

######  Einstellungen fuer den Block  ###################################################
// CHANGE THIS IF YOU CHANGE THE CALENDAR-MODULES FOLDER NAME
if (!defined("CAL_MODULE_NAME")) define("CAL_MODULE_NAME","Kalender");
#########################################################################################
// verschiedene Einstellungen
$sort = "asc";                  # Sortierung der Liste:  asc =aufsteigend / desc =absteigend
$scrolling = 0;                # Eintraege scrollen
$scrolldirection = "up" ;   # Richtung des Scrollens: up / down
$scrollheight = 170 ;         # Hoehe des scrollenden Bereichs
$scrolldelay = 1 ;           # Scrollgeschwindigkeit
$scrollamount = 1 ;           # Scrollgeschwindigkeit
$listcount = 50 ;                # count of entries in the List-Block
$listEnddate = 0 ;            # display the ending Date in List-View: 0=nein / 1=ja
$listStarttime = 0 ;         # display the starting Time in List-View: 0=nein / 1=ja
$listEndtime = 0 ;            # display the ending Time in List-View: 0=nein / 1=ja
$showNewlink = 1 ;            # Link Event vorschlagen anzeigen: 0=nein / 1=ja
$showLegend = 0 ;               # Farblegende anzeigen: 0=nein / 1=ja
######### Definition der Farben und Rahmen ###############################################################
$listbgcolor1 = $bgcolor1;               # Hintergrund erste Zeile  ( "" fuer Transparent  )
$listtxtcolor1 = $textcolor1;            # Text erste Zeile
$listbgcolor2 = $bgcolor2;               # Hintergrund naechste Zeile
$listtxtcolor2 = $textcolor2;            # Text naechste Zeile
$listbordercolor = $bgcolor3;            # Rahmenfarbe um Liste
$scrollbgcolor = $bgcolor1;               # Hintergrundfarbe des Marquee-Tags (Zwischenraum Scrollinhalte)
$listtableborder = 0;                        # html Rahmen um Liste
$listtablecellspacing = 1;               # abstand zwischen Events (auch Rahmenbreite)
$listtablecellpadding = 2;             # this will make the Events lines larger or smaller depending on value
###### Ende der Einstellungen, ab hier nichts veraendern !! ###############################################

$conftest =  @include("modules/".CAL_MODULE_NAME."/config/config.php");
if (!$conftest){
   $content = "<b>Error!</b><br>You must change the constant '\"CAL_MODULE_NAME\"' in file: <br>".__file__."";
   return;
   }
get_lang(CAL_MODULE_NAME);
if (!defined("CAL_MODULE_PATH"))  define("CAL_MODULE_PATH","modules/".CAL_MODULE_NAME."/");
if (!defined("CAL_TABLE_EVENTS")) @include_once(CAL_MODULE_PATH."includes/functions.php");

$showNewlink = (calIsPostAllowed() && $showNewlink) ? 1 : 0;
if (!calDetectGoodBrowser ()) {$scrolling=0;}
$whereoption= " categorie in(".calGetSqlEventpoints().") AND activ=1";
$d = (int)Date("d");
$m = Date("n");
$y = (int)Date("Y");


$tomorrow  = date("Y-n-d", mktime(0, 0, 0, date("m")  , date("d")+7, date("Y")));
$qrydate = "$y-$m-$d";

$qry="SELECT count(eid) FROM ".CAL_TABLE_EVENTS."
WHERE (startDate>= '$qrydate' and startDate<= '$tomorrow')
and ($whereoption) ";
$result = sql_query($qry, $dbi);
list($icount) = sql_fetch_row($result, $dbi);
if ($icount>$listcount) $icount=$listcount;



$i = 0;
$a = 0;


if ($icount) {
   setlocale (LC_TIME, _CALLOCALE);
   $imgprops= "align=\"middle\" hspace=\"1\" vspace=\"2\" width=\"9\" height=\"9\" border=\"0\" alt=\"\"";
   $content.="<table cellspacing=\"$listtablecellspacing\" cellpadding=\"$listtablecellpadding\" style=\"background-color: $listbordercolor; border: ${listtableborder}px solid $listbordercolor;\" border=\"$listtableborder\" width=\"100%\">";
   $qry="SELECT eid, title, hometext, posteddate, topic, informant, year(startDate), month(startDate), dayofmonth(startDate), hour(startTime), minute(startTime), year(endDate), month(endDate), dayofmonth(endDate), hour(endTime), minute(endTime), alldayevent, categorie FROM ".CAL_TABLE_EVENTS."
   WHERE (startDate>= '$qrydate' or endDate>= '$qrydate')
   and ($whereoption)
   order by startDate $sort, endDate $sort
   limit 0,$icount";
   $result=sql_query($qry, $dbi);
   
do {
   
   $compare = date("d.m.y", mktime(0, 0, 0, date("m")  , date("d")+$a, date("y")));
   $pisi = date("d", mktime(0, 0, 0, date("m")  , date("d")+$a, date("Y")));
         $content.="<tr style=\"background-color: $bgcolornew;\">
      <td valign=\"top\" width=\"15%\">$pisi</td>\n<td width=\"85 %\">";
   while(list($eid, $title, $hometext, $posteddate, $topic, $informant, $y1, $m1, $d1, $h1, $mi1, $y2, $m2, $d2, $h2, $mi2, $alldayevent, $categorie) = sql_fetch_row($result, $dbi)) {
      $title = htmlspecialchars(strip_tags(stripslashes($title)), ENT_QUOTES);
      $fontstyle = ($listStarttime) ? "tiny" : "content";
      $dateStart = strftime(_CALSHORTDATEFORMAT, @mktime(0, 0, 0, $m1, $d1, $y1));
      if ($listStarttime && !$alldayevent) {
         $dateStart.= " ".strftime(_CALTIMEFORMAT, @mktime($h1, $mi1, 0, $m1, $d1, $y1));
         }
      if ($dateStart == $compare) {   
      $dateEnd = ($listEnddate) ? strftime(_CALSHORTDATEFORMAT, @mktime(0, 0, 0, $m2, $d2, $y2)) : "";
      if ($listEndtime && !$alldayevent) {
         $dateEnd.= " ".strftime(_CALTIMEFORMAT, @mktime($h2, $mi2, 0, $m2, $d2, $y2));
         }
      $bgcolornew = ($i==0) ? $listbgcolor1 : $listbgcolor2;
      $txtcolornew = ($i==0) ? $listtxtcolor1 : $listtxtcolor2;
      $i = ($i==0) ? 1 : 0;
      $alttext = ($hometext && !$scrolling) ? substr(htmlentities(strip_tags(stripslashes($hometext))),0,70).'...' : "";}

      if ($dateStart == $compare) {   
      $content.="<img src=\"".calGetBarImage("ball",$categorie)."\" $imgprops><span style=\"color: $txtcolornew;\" class=\"tiny\">
      <a href=\"".CAL_MODULE_LINK."&amp;op=view&amp;eid=$eid\" style=\"text-decoration: none;\">$title</a></span><br>\n"; }

      }      
   $content.="</td>\n</tr>\n";   
   $a = $a+1;
}
while ($a < 7);
      $content.= "</table>";
      
   setlocale (LC_TIME, $GLOBALS["locale"]);
   }
else {
   $content.= "<span class=\"tiny\">"._CAL0EVENTSBLOCK."<br></span>\n";
   }
$bgcolornew = ($i==1) ? $listbgcolor2 : $listbgcolor1;

if ($showNewlink) {
   $content.="<hr size=\"1\" style=\"color: $listbgcolor2;\" width=\"100%\" noshade>";
   $content.="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><a href=\"".CAL_MODULE_LINK."&amp;file=submit\"><img src=\"".CAL_IMAGE_PATH."sign.gif\" alt=\""._CALSUBMITEVENT."\" width=\"16\" height=\"16\" border=\"0\" align=\"middle\" hspace=\"0\" vspace=\"1\"></a></td><td valign=\"middle\"><span class=\"tiny\">&nbsp;<a href=\"".CAL_MODULE_LINK."&amp;file=submit\">"._CALSUBMITEVENT."</a></span></td></tr></table>";
   }
if ($showLegend) {
   $imgprops= "align=\"middle\" hspace=\"6\" vspace=\"3\" width=\"9\" height=\"9\" border=\"0\" alt=\"\"";
   $content.="<hr size=\"1\" style=\"color: $listbgcolor2;\" width=\"100%\" noshade>\n";
   $content.=calBuildColorLegendSideBlocks();
   }

$content .= "\n<!-- $thisfile output end -->\n<!-- KalenderMx © by shiba-design.de -->\n";
$content = ereg_replace("\t","",$content);


/// Der Blocktitel wird über die Sprachdatei des Kalenders gesteuert,
/// soll statt dessen die Einstellung des Adminmenüs verwendet werden,
/// einfach die folgenden Zeilen löschen oder auskommentieren
$blockfiletitle = _CALLISTDESCRIPTION3;

?>
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Seeking applications ...

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©