Location: PHPKode > projects > Mozart > Mozart-0.0.4/projectlist.php
<?
// called from: index.php and programs called by it
// description: displays PROJECT by various inputs (type, UserID, etc.)
//
include("connect.inc");
include("reqlogin.inc");
include("userprefs.inc");
?>
<html>
<title>Mozart: Project Listing</title>
<body bgcolor=<? echo $bgcolor ?> text=<? echo $txtcolor ?>>
<?
include("links.inc");
?>
<center>
<br>
<b>Project Listing</b>
<br>
<? print("<font color=red>$Message</font>"); ?>
<form action="projectlist.php" method="post">
<?

$ProjectTypeSQL = "SELECT type_id, type_name FROM types WHERE type_source = 'Project' ORDER BY type_name";
$ProjectType    = mysql_query($ProjectTypeSQL);

if ($ChangeIt) {
	$SearchSys = $ChangeUser;
}
else {
	$SearchSys = $UserID;
}
?>
Show <select name=Type>
<option value=All>All
<?
while ($TypeData = mysql_fetch_array($ProjectType)) {
	if ($Type == $TypeData["type_id"]) {
		$selected = " selected";
	}
	else {
		$selected = "";
	}
	printf("<option value=%s%s>%s", $TypeData["type_id"], $selected, $TypeData["type_name"]);
}
?>
</select>
Projects for <select name=ChangeUser>");
<?
print("<option value=All>All");
include("getallusers.inc");
while ($ownerdata = mysql_fetch_array($OwnerData)) {
	if ($ownerdata["user_id"] == $SearchSys) {
		$selected = " selected";
	}
	else {
		$selected = "";
	}
	printf("<option value=%s%s>%s", $ownerdata["user_id"], $selected, $ownerdata["system_id"]);
}
print("</select>");
print("<input type=submit value=Find name=ChangeIt>");

if ($ChangeIt) {
	if ($SearchSys == "All") {
	    if ($Type == "All") {
		$ListSQL = "SELECT * FROM project ORDER BY name, number";
	    }
	    else {
		$ListSQL = "SELECT * FROM project WHERE type = '$Type' ORDER BY name, number";
	    }
	}
	else {
	   if ($Type == "All") {
		$ListSQL = "SELECT * FROM project WHERE owner = '$SearchSys' ORDER BY name, number";
	   }
	   else {
		$ListSQL = "SELECT * FROM project WHERE owner = '$SearchSys' AND type = '$Type' ORDER BY name, number";
	   }
	}
}
elseif (!$beg AND !$Type) {
	$ListSQL = "SELECT * FROM project WHERE owner= '$SearchSys' ORDER BY name, number";
}
elseif (!$end AND !$Type) {
	$ListSQL = "SELECT * FROM project WHERE name >= '$beg' AND owner = '$SearchSys' ORDER BY name, number";
}
elseif ($Type) {
	if ($Type == "All") {
		$ListSQL = "SELECT * FROM project WHERE owner = '$SearchSys' ORDER BY name, number";
	}
	else {
        	$ListSQL = "SELECT * FROM project WHERE type = '$Type' AND owner = '$SearchSys' ORDER BY name, number";
	}
}
else {
	$ListSQL = "SELECT * FROM project WHERE name >= '$beg' AND name < '$end' AND owner = '$SearchSys' ORDER BY name, number";
}
?>

<table border=1 cellspacing=0 cellpadding=0>
<?
$List = mysql_query($ListSQL);
$errno = mysql_errno($db);
$error = mysql_error($db);
if ($errno != 0) {
   printf("<tr><td>No Projects Found for Selected User(%s)</td></tr>", $errno);
}
else {
  while ($myrow = mysql_fetch_array($List)) {
    $proj_status = $myrow["status"];
    $StatusSQL = "SELECT type_name FROM types WHERE type_id = '$proj_status'";
    $Status    = mysql_query($StatusSQL);
    $status    = mysql_fetch_array($Status);
    printf("<tr><td><a href=\"%sprojectdisplay.php?id=%s\">%s %s %s</a></td>", $PHPSELF,
  $myrow["proj_id"], $myrow["name"], $myrow["number"], $myrow["middle"]);
    printf("<td><a href=\"%supdproject.php?id=%s\">Update</td>", $PHPSELF, $myrow["proj_id"]);
    printf("<td><a href=\"%sdelproject.php?id=%s\">Delete</td>", $PHPSELF, $myrow["proj_id"]);
    if ($status["type_name"] == "Closed") {
        print("<td><font color=red>Closed</font></td>");
    }
    else {
        printf("<td>%s</td>", $status["type_name"]);
    }
  ?></tr><?
  }
}
?>
</table>
<br>
</form>
</center>
<?
include("links.inc");
?>
</body>
</html>
Return current item: Mozart