WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 php3 and MySQL
Categories : PHP, Complete Programs, MySQL Update Picture
Greg Kelley
Date : Jan 13th 2000
Grade : Be the 1st to grade this Code Example
Viewed : 7129
File : websched.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  Submit your own code examples 
 

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>&nbsp;</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
fforum fumanchi forum MySQL treestructure
Categories : Complete Programs, PHP, MySQL
Tropicalm Genetree Family (MySQL based family tree)
Categories : PHP, Interfaces, Databases, MySQL, Complete Programs
OPiuM - stock Options Portfolio Manager for PHP and mySQL (secure encode/decode)
Categories : PHP, Complete Programs, MySQL
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
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
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
Education Center is a set of PHP-scripts to administer a corporate education and examination system via Internet/intranet written in PHP for MySQL.
Categories : PHP, Databases, MySQL, Complete Programs
myCSV-dump converts a simple CSV-flatfile-database into an MySQL-dump.
Categories : PHP, MySQL, Databases, Complete Programs
AITSH Download
Categories : PHP, Complete Programs, MySQL, Databases
DDN FFA Network Script
Categories : PHP, MySQL, Complete Programs, HTML and PHP, Databases
Shopping Basket On-Line Ordering System.
Categories : Complete Programs, MySQL, PHP, Ecommerce, Databases
DirtSearch Version 3.5 full function robust PHP and MySQL (and other databases) Site or Web Wide Search Engine
Categories : PHP, MySQL, Complete Programs, Search, Databases
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
Web Self Service Resource Scheduler Using Session Variables under php4 includes Calendar building code - requires MySQL
Categories : PHP, Complete Programs, Calendar, MySQL, Databases
 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)&gt;0) 

any idea????