How would I build this task management site?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ChrisF79
Forum Commoner
Posts: 26
Joined: Tue Apr 01, 2008 8:26 pm

How would I build this task management site?

Post by ChrisF79 »

I want to build a website that helps users with a specific task. Let's say for example it's a site on building a house. There's a definite order of things that need to be done (i.e. can't lay carpet before pouring the slab). I want users to be able to check off that they've poured the slab and it'll be marked done.

I will be putting all of the tasks in a "tasks" table. There will be a prerequisites table to make sure a user is allowed to check off a task.

ALl of that is fine. However, when it comes down to coding the site, I'm having trouble figuring out how I'm going to have one more level of options for certain items. As an example, I'd like for someone to be able to check off "Chose a contractor" and a form will pop up asking them to enter the contractor's contact information. On other choices, there isn't anything else to do other than simply check off the choice.

How would you go about coding this up? I can't wrap my head around the part where some items will have additional information the user can add.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: How would I build this task management site?

Post by Jade »

I would use some javascript and hidden DIV layers. If you have a checkbox with sub-questions then you can run a toggleShowHideDiv("div_name_here") using an onClick() for that specific checkbox. That means the DIV layer will only show up if they click on the checkbox that has additional questions attached to it. Then if they uncheck the box your toggleShowHideDiv function would need to hide the DIV layer again.
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

Re: How would I build this task management site?

Post by danwguy »

I would use this... it's ugly but it should work and obviously you need to fill in all your data, but this method will allow exactly what you need, just not on the same page.
Page1

Code: Select all

<?php
$database = "yourdatabaselink";
$user = "username";
$pass = "password";
$db = "db";
$table = "yourtable";

$con = mysql_connect($database, $user, $pass);
	if(!$con) {
			die("Could not connect to database: " .mysql_error());
			}
		@mysql_select_db($db) or die("Could not select database: " .mysql_error());
		$result = mysql_query("SELECT * FROM "' .$table. '" ORDER BY id DESC") or die("Could not SELECT: " .mysql_error());
		while($row = mysql_fetch_array($result) {
					//define variables here ill use one as example
					$contractor = $row['contractor'];
					}
					echo "<form action='post.php' method='post' name='list' id='list'>";
					echo "<div id='contractor'>Have you selected a contractor?<input type='radio' name='yes' id='yes' value='1' />Yes &nbsp; &nbsp; &nbsp;<input type='radio' name='no' id='no' value='0' />No";
					//echo all of your other stuff here
					//and do whatever else you want on this page
?>
Then on your post.php page do something like this.

Code: Select all

<?php
$contractor = $_POST['contractor'];
//all your other variables here
if($contractor == '1') {
		echo "<form action='adddata.php' method='post' name='whatever' id='whatever'>";
		echo "<strong><u>Contractor Information</u></strong>";
		echo "
		echo "<input type='text' maxlength='50' name='fname' /><br />";
		echo "<input type='text' maxlength='50' name='lname' /><br />";
		//and so on and so forth
		//add the data to your db
		}
	//finish up with whatever you want here.
?>
Again, ugly as hell and you need all your variables plugged in but it will work.
Post Reply