PHP
  Home arrow PHP arrow Page 3 - Viewing and Editing Tasks for a Projec...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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

Viewing and Editing Tasks for a Project Management Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-06-30

    Table of Contents:
  • Viewing and Editing Tasks for a Project Management Application
  • The edit_task script
  • Script Explained
  • HTML Form

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Viewing and Editing Tasks for a Project Management Application - Script Explained


    (Page 3 of 4 )

    So let's look at the code:


    <?php

    include "dbcon.php";

    include "functions.php";


    The code cleans the two IDs that it receives, before using them in queries. The "tid" is a task ID and the "pid" is a project ID. Ideally, we would not need the project ID, but we need it to retrieve the project name in order to display it on the form. Also, without the name of the project prominently displayed across the form, some users might forget which project they are editing the tasks for:


    $cpid=mysql_escape_String($_GET['pid']);

    $tpid=mysql_escape_String($_GET['tid']);


    First we retrieve the title of the project from the projects table, using the project ID that we received, and store the name in the $title variable:


    $getname = "SELECT title FROM projects WHERE pid = '".$cpid."'";

    $g_result = mysql_query($getname);

    if(!$g_result){

    echo mysql_error();

    }else{

    $rowname = mysql_fetch_assoc($g_result);

    $title = $rowname['title'];

    }


    Next, the code retrieves the specific task based on the task ID rather than the project ID. There might be more than one task with the same project ID, so it is safer to do it this way:


    $gettask= "SELECT * FROM tasks WHERE tid = '".$ctid."'";

    $t_result = mysql_query($gettask);

    if(!$t_result){

    echo mysql_error();

    }else{


    The result of the query is stored in the "$rowtask" variable:


    $rowtask = mysql_fetch_assoc($t_result);

    }


    We run this query to populate the HTML form with the task data. The next part of the code deals with updating the task. It receives the form data, does the security checks, and then runs the query to update the table:


    if(isset($_POST['submit'])){

    //check vars

    $descr=mysql_escape_string($_POST['descr']);

    $p_pid=mysql_escape_string($_POST['p_pid']);


    //build date

    $duedt = $_POST['yy'] . "-";

    if($_POST['mm'] < 10) {

    $duedt .= "0";

    }

    $duedt .= $_POST['mm'] . "-";

    if($_POST['mm'] == 4 || $_POST['mm'] == 6 || $_POST['mm'] == 9 || $_POST['mm'] == 11) {

    if($_POST['dd'] > 30) {

    $duedt .= "30";

    } else {

    $duedt .= $_POST['dd'];

    }

    } elseif($_POST['mm'] == 2) {

    if($_POST['yy'] == 2008 || $_POST['yy'] == 2012) {

    if($_POST['dd'] > 29) {

    $duedt .= "29";

    } else {

    $duedt .= $_POST['dd'];

    }

    } else {

    if($_POST['dd'] > 28) {

    $duedt .= "28";

    } else {

    $duedt .= $_POST['dd'];

    }

    }

    } else {

    $duedt .= $_POST['dd'];

    }

     

    //insert

    $update = "UPDATE tasks SET task_description = '".$descr."',";

    $update .= "complete_by = '".$duedt."',p_id= '".$p_pid."'";

    if(!mysql_query($update)){

    echo mysql_error();

    }

    }

    ?>

    More PHP Articles
    More By David Web


     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




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