Home arrow PHP arrow Page 8 - Time is Money (part 1)

Too Much Information - PHP

For consultancies that bill on an hourly basis - lawyers,accountants et al - time tracking is a critical part of the billingprocess. For small- and medium-size organizations, resource tracking,allocation and analysis is essential for business efficiency and planning.This article addresses both requirements by teaching you how to build atimesheet system to track and analyze work hours with PHP and MySQL.

TABLE OF CONTENTS:
  1. Time is Money (part 1)
  2. Up A Creek
  3. Bills, Bills, Bills
  4. So Many Tables, So Little Time
  5. Open Sesame
  6. The Lazy Programmer Strikes Again
  7. Today's Menu
  8. Too Much Information
  9. Time For Bed
By: The Disenchanted Developer, (c) Melonfire
Rating: starstarstarstarstar / 5
October 22, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
With the main menu out of the way, let's now begin putting together the scripts corresponding to the different menu options. The first of these is the script "projects.php", which allows users to view a list of active projects.

This is a very simple script - all it needs to do is connect to the database, retrieve a list of project names and associated descriptions, and print them in a neat list.

<? // projects.php - display project list // includes include("config.php"); include("functions.php"); // check for valid user session session_start(); if(!session_is_registered("SESSION_UID")) { header("Location: error.php?ec=1"); exit; } ?> <html> <head> <basefont face="Verdana"> <style type="text/css"> TD {font-family: Verdana; font-size: smaller} </style> </head> <body bgcolor="white"> <? // display page header $title = "<a style=color:white href=menu.php>Main Menu</a> > View Project Descriptions"; include("header.inc.php"); ?> <!-- main table --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" align="left" width="60%"><b><font color="#3098C3">Project Descriptions</font></b></td> </tr> <tr> <td>&nbsp;</td> </tr> <? // open connection to database $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); // get project names and descriptions $query = "SELECT pname, pdesc FROM projects"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // iterate through resultset and display while (list($pname, $pdesc) = mysql_fetch_row($result)) { echo "<tr><td><ul><b><li>$pname</b><br>$pdesc</td>"; echo "<tr><td>&nbsp;</td>"; } // close connection mysql_close($connection); ?> </table> <? include("footer.inc.php"); ?> </body> </html>
It looks simple, and it is. Here's what the output looks like:



Almost identical in function is the script "tasks.php", which displays a list of standard tasks, together with definitions for each. The only difference lies in the query that is used - as you can see:

<? // tasks.php - display task list // includes // check for valid user session // display page header // open connection to database $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); // get project names and descriptions $query = "SELECT tname, tdesc FROM tasks"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // iterate through resultset and display while (list($tname, $tdesc) = mysql_fetch_row($result)) { echo "<tr><td><ul><b><li>$tname</b><br>$tdesc</td>"; echo "<tr><td>&nbsp;</td>"; } // close connection mysql_close($connection); // include page footer ?>
And here's what this baby looks like:



 
 
>>> More PHP Articles          >>> More By The Disenchanted Developer, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: