PHP
  Home arrow PHP arrow Page 2 - Time Is Money (part 2)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Time Is Money (part 2)
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2001-11-16


    Table of Contents:
  • Time Is Money (part 2)
  • Getting Creative
  • Split Personality
  • In...
  • ...And Out
  • The Number Game
  • Exercising Restraint
  • The Big Picture...
  • ...And The Little Brush Strokes
  • When Things Go Wrong
  • Happy Endings

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Time Is Money (part 2) - Getting Creative
    ( Page 2 of 11 )

    If you look at the main menu, you'll see that the third menu item allows the user to view entries for a specified date. When you analyze this a little, though, you'll see that this menu item has broader implications - it must allow the user to:

    view a list of timesheet entries for the specified date;

    add new entries for the specified date;

    delete existing entries from the list.

    In order to perform these functions, the script - I've called it "view.php" - must necessarily receive a valid datestamp (created from the variables $d, $m and $y). These three variables are generated from the drop-down boxes in "menu.php" - you may remember this from last time's article (if not, I'd strongly suggest you review the source code for "menu.php" and then come back here). Once "view.php" receives these values, it generates a datestamp, checks to ensure that the date is a valid one, and then queries the "log" table for all relevant data.

    So that takes care of displaying existing entries. But what about adding new ones, or deleting existing ones?

    Well, after much thought and a couple of conversations with our resident interface designer, I've come up with a clever way to combine both these functions into "view.php". Here's a rough sketch of what I have in mind:



    Essentially, I plan to split the page into two main sections. The left side of the page will contain a list of entries retrieved from the database, with a checkbox next to each; the user can select an entry for deletion by checking the corresponding box. The right side of the page will hold a form, which can be used to add new entries to the timesheet. Entries added from the form on the right side will immediately appear in the list on the left side.

    This sounds complicated, but it's actually not all that difficult to implement. The important thing here is to take the pieces one at a time and deal with them separately. And so, the first thing I need to do is set up a page template.

    <? // view.php - view/add/delete entries for a specific date // includes // check for valid user session session_start(); if(!session_is_registered("SESSION_UID")) { header("Location: error.php?ec=1"); exit; } // check for valid date if (!checkdate($m, $d, $y)) { header("Location: error.php?ec=2"); exit; } <html> <head> </head> <body bgcolor="white"> <? // display page header ?> <!-- table (1r, 3c) --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" align="left" width="60%"> <!-- table for existing timesheet records goes here - snip --> </td> <!-- spacer --> <td width="10%"> &nbsp; </td> <td valign="top" align="left" width="30%"> <!-- table for new timesheet records goes here - snip --> </td> </tr> </table> <? // display page footer ?> </body> </html>
    The script begins with the usual checks and includes, and generates an HTML page containing a (1r, 3c) table. The first and last of these cells will be used for the existing and new timesheet data respectively.

    Note the checkdate() function at the top of the script - I'm using this to validate the date value received by "view.php". This check is necessary to catch incorrect date values - for example, 30 February or 31 April. If the date selected by the user is invalid, the script will redirect to the generic error handler, which should display a message indicating the error.

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

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT