What I need to do is find a calender - make it clickable and get it to send information to my mysql database.
http://www.phpclasses.org/browse/package/1870.html
pages to adapt to get the result I need
open /source/activecalendar.php
[script]
FIND:
function mkDay($var)
REPLACE the function with
function mkDay($var){
$eventContent=$this->mkEventContent($var);
$linkstr=$this->mkUrl($this->actyear,$this->actmonth,$var);
// delete string // key to this is function mkDelUrl that appears below
$deleteStr=$this->mkDelUrl($this->actyear,$this->actmonth,$var);
// I have added the following code to give the full date and a week count with year number :Deej
$this->thedaysfulldate = $this->actday.$this->actmonth.$this->actyear;
$weekCount = $this->getWeekNum($var).$this->actyear;
if ($this->javaScriptDay) $linkstr="javaScriptDay."(".$this->actyear.",".$this->actmonth.",".$var.")\">".$var."";
if ($this->isEvent($var)){
if ($this->eventUrl){
$out="
$this->eventUrl=false;
}
elseif (!$this->dayLinks) $out="
// the following is a highlighted box
// to delete from mysql this will be the place to add a get link for removal
else $out="
}
elseif ($var==$this->selectedday && $this->actmonth==$this->selectedmonth && $this->actyear==$this->selectedyear){
if (!$this->dayLinks) $out="
else $out="
}
elseif ($var==$this->daytoday && $this->actmonth==$this->monthtoday && $this->actyear==$this->yeartoday){
if (!$this->dayLinks) $out="
// underneath is the white highlighted box
else $out="
}
elseif ($this->getWeekday($var)==0 && $this->crSunClass){
if (!$this->dayLinks) $out="
// the following is on the sunday link that works
else $out="
}
elseif ($this->getWeekday($var)==6 && $this->crSatClass){
if (!$this->dayLinks) $out="
// the following is on the saturday link that works
else $out="
}
else{
if (!$this->dayLinks) $out="
// the following is on the day link that works
else $out="
}
return $out;
}
FIND
function mkUrl
UNDERNEATH THAT FUNCTION ADD:
/*
********************************************************************************
PRIVATE mkDelUrl() -> creates the day and navigation link structure
********************************************************************************
*/
function mkDelUrl($year,$month=false,$day=false){
if (strpos($this->url,"?") === false) $glue="?";
else $glue="&del";
if (strpos($this->urlNav,"?") === false) $glueNav="?";
else $glueNav="&";
$yearNavLink="urlNav.$glueNav.$this->yearID."=".$year."\">";
$monthNavLink="urlNav.$glueNav.$this->yearID."=".$year."&del".$this->monthID."=".$month."\">";
$dayLink="url.$glue.$this->yearID."=".$year."&del".$this->monthID."=".$month."&del".$this->dayID."=".$day."\">".$day."";
if ($year && $month && $day) return $dayLink;
if ($year && !$month && !$day) return $yearNavLink;
if ($year && $month && !$day) return $monthNavLink;
}
MAKE A NEW FILE
-> i'm just going to list the important bits of the page here. so you'll need to format it how you want.
in the php tags
require_once("../source/activecalendar.php");
$myurl=$_SERVER['PHP_SELF']."?css=".@$_GET['css']; // the links url is this page
$yearID=$_GET['yearID'];; // init false to display current year
$monthID=false; // init false to display current month
$dayID=false; // init false to display current day
$cal=new activeCalendar($yearID,$monthID,$dayID);
$cal->enableDayLinks($myurl); // enables day links
$thisYear=$cal->actyear; // get the current year
$arrowBack="<<"; // arrow back
$arrowForw=">>"; // arrow forward
$_SESSION['uid'] = $uid;
$_SESSION['pwd'] = $pwd;
$rst=mysql_query("SELECT * FROM users WHERE email='$uid' and passwd='$pwd'");
$row = mysql_fetch_array($rst);
$llid=$row["llid"];
$dateRst =mysql_query("SELECT * FROM weeks WHERE llid='$llid'");
while ($rows = mysql_fetch_array($dateRst))
{
$dayID = $rows['dayID'];
$monthID = $rows['monthID'];
$yearID = $rows['yearID'];
$llid = $rows['llid'];
$weekFinish = $dayID+7;
for ($x=$dayID;$x<=$weekFinish;$x++) $cal->setEvent($yearID,$monthID,$x); // create a class="event" from 10th till 20th on March each year
}
//$cal->setEvent("08","1","17","event"); // create a class="event" on the 17th Jan each year
//for ($x=5;$x<=12;$x++) $cal->setEvent("08",$x,"24"); // create a class="event" on the 23th from May till December each year
$cal->enableYearNav($myurl,$arrowBack,$arrowForw); // enables navigation controls
$cal->enableDatePicker(2008,2018,$myurl); // enables date picker (year range 2000-2010)
if ($_GET['dayID'] && $_GET['monthID'] && $_GET['yearID'] ){
$dayID = $_GET['dayID'];
$monthID = $_GET['monthID'];
$yearID = $_GET['yearID'];
// the mysql query will depend on what information your using in your project
$rst=mysql_query("SELECT * FROM users WHERE email='$email' and passwd='$passwd'");
if ($row = mysql_fetch_array($rst))
{
$llid=$row["llid"];
// db insert and redirection
mysql_query ("INSERT INTO weeks (llid, dayID, monthID, yearID) VALUES ('$llid', '$dayID', '$monthID', '$yearID')");
echo 'These details have been added to the database '.$dayID.' '.$monthID.' '.$yearID.' ';
}
}
if ($_GET['deldayID'] && $_GET['delmonthID'] && $_GET['delyearID'] ){
$dayID = $_GET['deldayID'];
$monthID = $_GET['delmonthID'];
$yearID = $_GET['delyearID'];
// the mysql query will depend on what information your using in your project
$rst=mysql_query("SELECT * FROM users WHERE email='$email' and passwd='$passwd'");
if ($row = mysql_fetch_array($rst))
{
$llid=$row["llid"];
// db insert and redirection
// this is where I'm upto - i know its the following statement at fault
// as when I change & to AND it deletes all my records under llid
mysql_query ("DELETE FROM weeks WHERE (llid = '$llid' && dayID ='$dayID' && monthID ='$monthID' && yearID ='$yearID') ");
echo 'These details have been deleted from the database '.$dayID.' '.$monthID.' '.$yearID.' ';
}
}
THEN INSIDE THE HTML
call up the class with
showYear(); ?>
[/script]
*****************************
Thats it. I am aware that this is somewhat of a hack and am always looking a improving my code. I think that ideally a class addition somehow would have been better, rather than changing function mkDay.
Anyone reading this who can help me out on that please let me know.
*****************************