WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Web Self Service Resource Scheduler Using Session Variables under php4 includes Calendar building code - requires MySQL
Categories : PHP, Complete Programs, Calendar, MySQL, Databases Update Picture
Greg Kelley
Date : Jan 14th 2000
Grade : 5 of 5 (graded 1 times)
Viewed : 10948
File : websched_session.tar
Images : No Images for this code example.
Search : More code by Greg Kelley
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

This is a complete System for creating a self-service resource scheduler. Originally done using
cookies to track individual 'session' variables (commented out in this code but still remain) for
use under php3. Recently modified to support php4 sessions. Sample of main calendar file
below, full code in attached .tar file.

<?

require("sched.inc");
require("datefunc.inc");

session_start();
session_register("sess_yr");
session_register("sess_mth");
session_register("row");
session_register("sess_ID");
session_register("sess_rdate");
session_register("sess_Date");
session_register("sess_sTime");
session_register("sess_eTime");
session_register("sess_Resrc");
session_register("sess_Descr");

$conn=mysql_pconnect($host,$user,$pwd);
mysql_select_db($db,$conn);

if ($add=="Add")
{
header("Location: addrec.php");
mysql_free_result($result);
mysql_close($conn);
        exit;
}

$tdate=strftime("Y-m-d");

// $Sched_yr=$HTTP_COOKIE_VARS["Sched_yr"];

if ($sess_yr=="")
{
$tyr=sprintf("%d",strftime("%Y"));
// setCookie("Sched_yr",$tyr,0,"/",$SERVER_NAME,0);
$sess_yr=$tyr;
}
else
{
$tyr=$sess_yr;
}

// $Sched_mth=$HTTP_COOKIE_VARS["Sched_mth"];

if ($sess_mth=="")
{
$tmth=sprintf("%d",strftime("%m"));
// setCookie("Sched_mth",$tmth,0,"/",$SERVER_NAME,0);
$sess_mth=$tmth;
}
else
{
$tmth=$sess_mth;
}


// Calculate Current Month entering w/o Prev/Next
if ($sess_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;
}
$sess_mth=$tmth;
$sess_yr=$tyr;
// 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;
}
$sess_mth=$tmth;
$sess_yr=$tyr;
// 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;
}
}
}
}
mysql_free_result($result);
mysql_close($conn);

?>

<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.php" 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.php?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.php"><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>&nbsp;</td> --->
<td align="center"><font size="+2">
<!---<input type="submit" name="nxt" value="Next"></td>--->
<a href="default.php?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.php?rdate=<? echo $tdate; ?>"><? echo $j; ?></a></font>
</b></td>
<? }
else
{ ?>
<td align="center" bgcolor="white"><font size="+2"><b>
<a href = "daysched.php?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>





This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
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
Tropicalm Genetree Family (MySQL based family tree)
Categories : PHP, Interfaces, 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
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
Browse a MySQL database & draw a tree view & load final items into a template page.
Categories : MySQL, Complete Programs, Algorithms, PHP, Databases
Shopping Cart e-Commerce Solution
Categories : Complete Programs, PHP, MySQL, Databases
complete, simple, working example of a login screen/system using php functions, cookies, and a mysql database for begginers.
Categories : Authentication, Complete Programs, PHP, MySQL, Databases
AITSH Download
Categories : PHP, Complete Programs, MySQL, Databases
BBS system for easy customization. Utilizes mySQL.
Categories : Complete Programs, MySQL, PHP, Databases
 chris mccreadie wrote : 184
Well it looks good but it keeps refering to a file called 
sched.inc which I cant seem to find.
 
 Greg Kelley wrote : 186
Rename config.inc to Sched.inc
 
 Migell Acosta wrote : 409
The "Update" button on the "update.php" page won`t 
actually update my existing record.
 
 Stephen Burch wrote : 482
I`m pretty new with php and was wondering where the following files can be found?

sched.inc and datefunc.inc.  They are needed in a script that I have downloaded.  Sorry this is such a rudimentary question.

require("sched.inc"); 
require("datefunc.inc"); 
 
 Broom Neuenhause wrote :661
Kewl! It works perfectly, and it has already a nice layout...