Location: PHPKode > projects > Druid Defect Control > defectcontrol_0.9.4/tts/admintable.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>Administer table <?php echo "'$table'"?></h1>

<p>&nbsp;You can edit the content of any field or delete the entire row by clicking 
  the links on the first column.</p>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td>&nbsp;
<?php 
    
    if ($table == "") {
        tter_errorWithBackButton("No table has been specified.");
        exit;
    }
    
    $query = "select * from $table order by iid";
    $res = ttdb_execQuery($db, $query) or die("'$query' is not valid.");
    
    if ($keyfield == "") $keyfield = "iid";  // convenient default
    
    // Header
    for ($c = 0; $c < ttdb_getNumFields($res); $c++) {
?>
    <td><?php echo substr(ttdb_getFieldName($res, $c), 1); ?></td>
<?php  } // for ?>
  </tr>
  <tr>
<?php    
    // fields    
    while (($fields = ttdb_getArray($res)) != false) {
?>
<?php
        echo "<td nowrap><font size=2>";
        echo "<a href='adminfield.php?table=$table&keyfield=$keyfield&keyvalue=$fields[$keyfield]'>[Edt]</a>";
        echo "<a href='adminfield.php?table=$table&keyfield=$keyfield&keyvalue=$fields[$keyfield]&operation=delete'>[Del]</a>";
        echo "</td></font>";
        $a = 0;
        foreach ($fields as $key => $value) { ?>
    <td nowrap><font size=2>&nbsp;<?php echo $value; ?></font></td>
<?php      } // foreach ?>
  </tr>
<?php } // end while ?>
</table>
<br>
<div align="center">
<a href="adminfield.php?table=<?php echo $table?>&operation=add">Add new register</a>
</div>
<br>
<?php include 'footer.php'; ?>

</body>
</html>
Return current item: Druid Defect Control