Location: PHPKode > projects > Druid Defect Control > defectcontrol_0.9.4/tts/queryresult.php
<table class="tableStyle" width="100%" cellpadding=2>
<?php 

require_once 'errors.php';

/* 
    
    This file is responsible for showing the table with results of a query. 
    
    The format of the table is implemented here. 
    
    The query to be rendered by this script has to be in the variable 
    $tts_query. This is meant to avoid passing SQLs from the client.

    It IS important that columns do NOT have repeated names, as only 
    the latest will appear (use 'as' in the select to avoid duplicates)
 
 */

    $statusColors = array(
        "New" => "#FFEEEE",
        "Assigned" => "#FFEEEE",
        "Open" => "#FFEEEE",
        "Resolved" => "#EEFFEE",
        "Verified" => "#EEFFEE",
        "Duplicated" => "#EEFFEE",
        "Postponed" => "#FFFFCC"
     ); 


    define (DEFECT_ID_FIELD_NAME, "defectid");
    define (DEFECT_HEADLINE_FIELD_NAME, "headline");
    define (DEFECT_STATUS_FIELD_NAME, "status");
    define (DEFECT_PRIORITY_FIELD_NAME, "priority");

    if ($tts_query == "") {
        tter_errorWithBackButton("no query has been specified");
        exit;
    }

    ttdb_connect($db);

//    echo $tts_query;

    $res = ttdb_execQuery($db, $tts_query);

    $numFields = ttdb_getNumFields($res);
    
    echo "<tr class='tableTitle'>";
    
    for ($i = 0; $i < $numFields; $i++)     
        echo "<td><font size=2>".ttdb_getFieldName($res, $i)."</font></td>";
    
    echo "</tr>";

    $numLines = 0;
        
    while (($row = ttdb_getArray($res)) != false) {
            
        echo "<tr class='tableFieldContent'>\n";
        
/*        echo '<pre>';
        print_r($row);
        echo "</pre>\n";
*/       
        foreach ($row as $key => $value) { 

            echo '  <td class="tableFieldContent"';
            
            if ($key == DEFECT_ID_FIELD_NAME) {
                $id = $value;
            }
        
            if ($key == DEFECT_ID_FIELD_NAME) {
                
                echo "><a href=\"visualize.php?iddefect=$id\">$value</a>";
                
            } else if ($key == DEFECT_HEADLINE_FIELD_NAME) {
            
                echo "><a href=\"visualize.php?iddefect=$id\">".htmlspecialchars($value)."</a>";
                 
            } else if ($key == DEFECT_STATUS_FIELD_NAME) {
            
                echo "bgcolor='".$statusColors[$value]."'>$value";
            
            } else if ($key == DEFECT_PRIORITY_FIELD_NAME) {
                
                // Could put here logic for color change, but as it is a
                // db table, snames can change arbitrarily, and we donĀ“t 
                // have here the ids, so it is not easy to do it properly. 
                
                echo ">$value";  
            
            } else { // non - link field
            
                echo ">$value";
                
            }
            
            echo "</td>\n";
            
            
        } //foreach
        
        echo "</tr>\n\n";
        
        $numLines++;
        
    } //while

    echo "</table>"; 

    echo "<br>Total entries shown: $numLines\n\n";

    ttdb_close($db); 
    
?>
Return current item: Druid Defect Control