|
|
|
A complete self-service resource scheduler. Good examples of creating a calendar from
scratch and using cookies to create 'session' variables. Code for mail page below, complete
code in websched.tar file attached.
<?
require("config.inc");
require("datefunc.php3");
$conn=mysql_pconnect($host,$user,$pwd);
mysql_select_db($db,$conn);
if ($add=="Add")
{
header("Location: addrec.php3");
exit;
}
$tdate=strftime("Y-m-d");
$Sched_yr=$HTTP_COOKIE_VARS["Sched_yr"];
if ($Sched_yr=="")
{
$tyr=sprintf("%d",strftime("%Y"));
setCookie("Sched_yr",$tyr,0,"/",$SERVER_NAME,0);
$Sched_yr=$tyr;
}
else
{
$tyr=$Sched_yr;
}
$Sched_mth=$HTTP_COOKIE_VARS["Sched_mth"];
if ($Sched_mth=="")
{
$tmth=sprintf("%d",strftime("%m"));
setCookie("Sched_mth",$tmth,0,"/",$SERVER_NAME,0);
$Sched_mth=$tmth;
}
else
{
$tmth=$Sched_mth;
}
// Calculate Current Month entering w/o Prev/Next
if ($Sched_mth!="")
{
$nmth=$tmth+1;
$nyr=$tyr;
}
else
{
$nmth=sprintf("%d",strftime("%m"))+1;
$nyr=sprintf("%d",strftime("%Y"));
}
if ($nmth==13)
{
$nmth=1;
$nyr=$nyr+1;
}
$ndate=$nyr."-".$nmth."-1";
if ($Sched_mth!="")
{
$cmth=$tmth;
$cyr=$tyr;
}
else
{
$cmth=strftime("%m");
$cyr=strftime("%Y");
}
$cdate=$cyr."-".$cmth."-1";
$mdays=datediff("d",$ndate,$cdate);
$tday=strftime("%w",mktime(0,0,0,$cmth,1,$tyr))+1;
$mstr=strftime("%B",mktime(0,0,0,$tmth,1,$tyr));
if ($nxt=="Next")
{
$tmth=$tmth+1;
if ($tmth==13)
{
$tmth=1;
$tyr=$tyr+1;
}
setCookie("Sched_mth",$tmth,0,"/",$SERVER_NAME,0);
setCookie("Sched_yr",$tyr,0,"/",$SERVER_NAME,0);
$tdate=$tyr."-".$tmth."-01";
$mstr=strftime("%B",mktime(0,0,0,$tmth,1,$tyr));
// compute days in month
$nmth=$tmth+1;
$nyr=$tyr;
if ($nmth==13)
{
$nmth=1;
$nyr=$nyr+1;
}
$ndate=$nyr."-".$nmth."-01";
$mdays=datediff("d",$ndate,$tdate);
$tday=strftime("%w",$tdate)-1;
$tday=strftime("%w",mktime(0,0,0,$tmth,1,$tyr))+1;
}
if ($prv=="Prev")
{
$tmth=$tmth-1;
if ($tmth==0)
{
$tmth=12;
$tyr=$tyr-1;
}
setCookie("Sched_mth",$tmth,0,"/",$SERVER_NAME,0);
setCookie("Sched_yr",$tyr,0,"/",$SERVER_NAME,0);
$tdate=$tyr."-".$tmth."-01";
$mstr=strftime("%B",mktime(0,0,0,$tmth,1,$tyr));
// compute days in month
$nmth=$tmth+1;
$nyr=$tyr;
if ($nmth==13)
{
$nmth=1;
$nyr=$nyr+1;
}
$ndate=$nyr."-".$nmth."-01";
$mdays=datediff("d",$ndate,$tdate);
$tday=strftime("%w",mktime(0,0,0,$tmth,1,$tyr))+1;
}
$sql="SELECT * FROM Sched WHERE month(schdate) = ".$tmth;
$result=mysql_query($sql,$conn);
for ($i=1; $i<=31; $i=$i+1)
{
$daysched[$i]=FALSE;
if (mysql_num_rows($result)>0)
{
mysql_data_seek($result,0);
while($rs=mysql_fetch_array($result))
{
$ty=strtok($rs["schdate"],"-");
$tm=strtok("-");
$td=strtok("-");
if ($tm==$tmth && $td==$i && $ty==$tyr)
{
$daysched[$i]=TRUE;
break;
}
}
}
}
?>
<html>
<head>
<title>Web Scheduler</title>
</head>
<body background="/images/white.jpg" bgcolor="Silver"><font face="Arial,Helv,Helvetica">
<center><font size="+3" color="Maroon"><strong>Web Scheduler</strong>
</font><br>
<font size="+2" color="Blue"><b><? echo $mstr; ?> <? echo $tyr; ?></b>
<form action="default.php3" method="POST">
<table border=1 cellspacing=2 bgcolor="white" bordercolor="Silver">
<tr>
<td align="center"><font size="+2">
<!---<input type="submit" name="prv" value="Prev"></td>--->
<a href="default.php3?prv=Prev"><img src="Prev.jpg" border="0"></a></td>
<td> </td>
<td> </td>
<td align="center"><font size="+2">
<!---<input type="submit" name="add" value="Add"></td>--->
<a href="addrec.php3"><img src="Add.jpg" border="0"></a></td>
<td> </td>
<td> </td>
<!---<td align="center"><font size="+2">
<input type="submit" name="upd" value="Upd"></td>
<td> </td> --->
<td align="center"><font size="+2">
<!---<input type="submit" name="nxt" value="Next"></td>--->
<a href="default.php3?nxt=Next"><img src="Next.jpg" border="0"></a></td>
</tr>
<tr>
<td align="center"><font size="+2">Sun</td>
<td align="center"><font size="+2"> Mon </td>
<td align="center"><font size="+2"> Tue </td>
<td align="center"><font size="+2">Wed</td>
<td align="center"><font size="+2"> Thu </td>
<td align="center"><font size="+2"> Fri </td>
<td align="center"><font size="+2">Sat</td>
</tr>
<? $i=1;
$j=0;
while($i<43)
{
if ($i==1 || $i==8 || $i==15 || $i==22 || $i==29 || $i==36)
{ ?>
<tr>
<? }
$j=$j+1;
if ($i<$tday || $j>$mdays)
{
$j=$j-1; ?>
<td align = "center"><font size="+2"> </td>
<? }
else
{
if ($daysched[$j])
{
$tdate=$tyr."-".$tmth."-".$j;
if ($j==strftime("%d") && $tmth==strftime("%m") && $tyr==strftime("%Y"))
{ ?>
<td align="center" bgcolor="silver"><font size="+2"><b>
<a href = "daysched.php3?rdate=<? echo $tdate; ?>"><? echo $j; ?></a></font>
</b></td>
<? }
else
{ ?>
<td align="center" bgcolor="white"><font size="+2"><b>
<a href = "daysched.php3?rdate=<? echo $tdate; ?>"><? echo $j; ?></a></font>
</b></td>
<? }
}
else
{
if ($j==strftime("%d") && $tmth==strftime("%m") && $tyr==strftime("%Y"))
{ ?>
<td align="center" bgcolor="silver"><font size="+2" color="Green">
<b><? echo $j; ?></b></td>
<? }
else
{ ?>
<td align="center" bgcolor="white"><font size="+2" color="Green">
<b><? echo $j; ?></b></td>
<? }
}
}
if ($i==7 || $i==14 || $i==21 || $i==28 || $i==35)
{ ?>
</tr>
<? }
$i=$i+1;
}
?>
</table>
</center></form>
<img src="/icons/redhatpb.gif" border="0"> <img src="/icons/apache_pb.gif"
border="0">
<img src="/icons/mysql.gif" border="0"> <img src="/icons/php.gif" border="0">
<p>
<font size="1" color="Black">
Please report any problems to <a href="mailto:gkelley@usnhmail.unh.edu">Greg Kelley</a>
</body>
</html>
|
|
| bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | fforum fumanchi forum MySQL treestructure Categories : Complete Programs, PHP, MySQL | | | Simple Mini Poll class library (SimPoll) Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs | | | Shopping Basket On-Line Ordering System. Categories : Complete Programs, MySQL, PHP, Ecommerce, Databases | | | free, search engine, indexing, system, information, web,
ftp, http, free, software, cgi, php, MySQL, database, php3,
FreeBSD, Linux, Unix, UdmSearch Categories : MySQL, Complete Programs, PHP, Databases, Search | | | Example voting script. Lets people enter suggestions and vote for existing ones. Categories : MySQL, PHP, Cookies, Complete Programs, Databases | | | Free For All Links Page using PHP3 and Mysql Categories : PHP, MySQL, Complete Programs | | | phpHoo2 (Xhoo using php3/MySQL) is a Yahoo-like link directory. Much like the Open Directory Project (dmoz.org). Categories : PHP, Complete Programs, Directories, MySQL, URLs | | | Browse a MySQL database & draw a tree view & load final items into a template page. Categories : MySQL, Complete Programs, Algorithms, PHP, Databases | | | PHP mySQL learning example This is a complete program to modify tables
in a mySQL database on a nice and neat way. Categories : PHP, MySQL, Complete Programs, HTML and PHP | | | Shopping Cart e-Commerce Solution Categories : Complete Programs, PHP, MySQL, Databases | | | This is a redirection program which is as good as the come.to v3 url
redirection, complete with admin interface all clients stored in mysql
Categories : PHP, MySQL, Ecommerce, HTML and PHP, Complete Programs | |
| | | | Greg Kelley wrote : 172
Small Fix to addupd.php:
Change if ($rs["resource"]==$trec)
to:
if ($rs["resource"]==$trec && $rs["ID"]!=$tid)
| | | | Greg Kelley wrote : 185
Rename config.inc to sched.inc and change references in
all .php files of config.inc to sched.inc, or change
references to config.inc only and leave filename alone.
| | | | jeff margel wrote :607
Gives me a `supplied agrument is not a valid mysql result resource error:
if (mysql_num_rows($result)>0)
any idea????
| |
|
|
|