Home arrow PHP arrow Page 4 - Making Changes in a Project Management Application

Determining the Value of the Variable - PHP

This is the third part of a seven part article series detailing the creation of a project management application. It will discuss how to make changes to the project, such as the project's status, via the edit_project.php script.

TABLE OF CONTENTS:
  1. Making Changes in a Project Management Application
  2. PHP Explained
  3. HTML Form
  4. Determining the Value of the Variable
By: David Web
Rating: starstarstarstarstar / 3
June 16, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

One of the three values is contained in the $projectdetails['status'] variable. The only difficulty here is that you need to show the other two values in case the user wants to change from the current status. For example, say the status of the project is 'pending.' The user loads the edit_project page and that is the status that he should see on the form. However, the user must also be able to change that status to any of the other two states (overdue and completed).

So, we need to create a select box that will show the current status of the project as well as give the user the option to change the status. The logical steps to take in this case, are to first determine what value is in the $projectdetails['status'] variable, and then use the select box 'selected' attribute to select that value. I've used the switch() structure to do that work for me:

<select name="status" id="status">

<?php

$list=array('overdue','completed','pending');


switch($projectdetails['status']){

 

case "overdue":

echo "<option value='overdue'

selected";

 

break;

case "completed":

echo "<option value='completed'

selected";

 

break;

case "pending":

echo "<option value='pending'

selected";

 

break;

}


Once I've determined what the value of the variable is and selected it, I then run a for() loop and list all three values in the select box. You will see that I created an array called $list (highlighted in red above) that contains all three values:


for($x=0; $x < 4; $x++){

echo ">" .$list[$x]. "</option>";

}

?>

</select>

<input type="hidden" name="p_pid" value="<?php echo $_GET['pid']?>"/>

</label></td>

</tr>

<tr>

<td>Date Due </td>

<td><label>

<?

$dd = date("d");

$mm = date("m");

$yy = date("Y");

echo "<select name="dd">n";

for($i = 1; $i <= 31; $i++) {

echo "<option value="" . $i . """;

if($i == $dd) {

echo " selected";

}

echo ">" . $i . "</option>n";

}

echo "</select>&nbsp;<select name="mm">n";

for($i = 1; $i <= 12; $i++) {

echo "<option value="" . $i . """;

if($i == $mm) {

echo " selected";

}

echo ">" . $month_names[$i] . "</option>n";

}

echo "</select>&nbsp;<select name="yy">n";

for($i = $yy; $i <= ($yy + 1); $i++) {

echo "<option value="" . $i . """;

if($i == $yy) {

echo " selected";

}

echo ">" . $i . "</option>n";

}

echo "</select>";

?>

<input type="hidden" name="createdt" value="<?php echo $projectdetails['create_dt']?>" />

</label></td>

</tr>

<tr>

<td>&nbsp;</td>

<td><label>

<input name="submit" type="submit" id="submit" value="Update!" />

</label></td>

</tr>

</table>


</form>

<!-- InstanceEndEditable --></td>

</tr>

<tr>

<td colspan="3"><!-- InstanceBeginEditable name="nav" --><table width="100%" border="0">

<tr>

<td><a href="edit_task.php?pid=<?php echo $projectdetails['pid'];?>">Change a Task in this Project</a> | <a href="edit_staff.php?pid=<?php echo $projectdetails['pid'];?>">Change Staff members of this Project </a> | <a href="main.php">View Project List</a> | <a href="admin/login.php">Administrators Corner </a> </td>

</tr>

</table><!-- InstanceEndEditable --></td>

</tr>

<tr>

<td align="right" class="cright" colspan="3">copyright &copy; 2007 PM </td>

</tr>

</table>

</body>

<!-- InstanceEnd --></html>


That's all there is to the edit project script. The next article will look at adding, editing, and viewing tasks for a particular project.



 
 
>>> More PHP Articles          >>> More By David Web
 

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: