Location: PHPKode > projects > Druid Defect Control > defectcontrol_0.9.4/tts/adminfield.php
<?php require_once 'usercheck.php' ?>
<?php require_once 'errors.php' ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css">
</head>

<body bgcolor="#FFFFFF">
<?php include 'header.php'; ?>

<?php
    // Check admin privilege
    ttdb_connect($db);
    if (ttus_userIsAdmin($db) != "t") {
        tter_errorWithBackButton("You are not authorized to perform this operation", "Access level error");
        exit;
    }
?>

<h1>
<?php
    switch ($operation) {
    case "delete": 
        echo "Confirm deletion of this entry"; 
        break;
    case "add":
        echo "Add new row";
        break;
    default: 
        echo "Edit row"; 
    }
?>
</h1>

<form method="post" action="adminfieldpost.php">
<input type="hidden" name="__table" value="<?php echo $table ?>">
<input type="hidden" name="__keyfield" value="<?php echo $keyfield ?>">
<input type="hidden" name="__keyvalue" value="<?php echo $keyvalue ?>">
<input type="hidden" name="__operation" value="<?php echo $operation ?>">

<table width="95%" border="1" cellspacing="0" cellpadding="5" align="center">
  <tr>
<?php 
    
    if ($operation == "add") 
        $query = "select * from $table";  // just to take the field names
    else
        $query = "select * from $table where $keyfield='$keyvalue'";
    
    $res = ttdb_execQuery($db, $query) or die("'$query' is not valid.");
    
    // Header
    for ($c = 0; $c < ttdb_getNumFields($res); $c++) {
?>
    <td>&nbsp;<?php echo substr(ttdb_getFieldName($res, $c), 1); ?></td>
<?php  } // for ?>
  </tr>
  <tr>
<?php    
   if ($operation == "add") {
        // add is a special case, as there will be no rows. 
        //echo ""; 
        for ($c = 0; $c < ttdb_getNumFields($res); $c++) {
            echo "   <td><input type='text' name='".ttdb_getFieldName($res, $c)."'></td>\n";
        }

    } else {
        // fields    
        $fields = ttdb_getArray($res);
        foreach ($fields as $key => $value) { 
            
            echo "<td nowrap><font size=2>&nbsp;";

            switch ($operation) {
            case "delete": 
                echo $value; 
                break;
            default: 
                // default, means edition
                echo "<input type='text' name='$key' value='$value'>";
            }

            echo "</font></td>";        
        } // foreach
    }  ?>
  </tr>
</table>
<p>
<div align="center">
<input type="submit" value="Accept">
<input type="button" value="Cancel">
</div>
</p>
</form>

<p>&nbsp;</p>
<p>&nbsp;</p>
<?php include 'footer.php'; ?>
</body>
</html>
Return current item: Druid Defect Control