Location: PHPKode > projects > AJAX MySQL Admin > ajaxmysqladmin/www/api/properties.php
<?php
    require_once ('inc/constants.inc');
    require_once ('inc/generic_start.inc');

    if ($_GET['action'] == 'list' && isset ($_GET['tname']) && isset ($_GET['label'])) {
        $tname = $_GET['tname'];
        $label = $_GET['label'];

        $query = "DESCRIBE `" . $tname . "`;";
        $conn = mysql_connect ($dbhost . ":" . $dbport, $dbuser, $dbpass);
        mysql_select_db ($dbname, $conn);
        echo "{" . NL;
        echo "page:1," . NL;
        echo "total:1," . NL;
        $result = mysql_query ($query, $conn);
        if ($result === FALSE || mysql_num_rows ($result) == 0) {
            echo "mysqlerror:'" . str_replace ('\'', '\\\'', mysql_error()) . "'," . NL;
            echo "response:0" . NL;
        } else {
            $count = 0;
            while ($row = mysql_fetch_array($result)) {
                if ($row ['Field'] == $label) {
                    $notNull = ($row ['Null'] == 'YES' ? 'No' : 'Yes');
                    $primaryKey = ($row ['Key'] == 'PRI' ? 'Yes' : 'No');
                    $key = ($row ['Key'] == 'MUL' ? 'Yes' : 'No');
                    echo "rows:[" . NL;
                    echo "{id:'Not Null', cell:['Not Null','" . $notNull . "']}," . NL;
                    echo "{id:'Primary Key', cell:['Primary Key','" . $primaryKey . "']}," . NL;
                    echo "{id:'Key', cell:['Key','" . $key . "']}," . NL;
                    echo "{id:'Extra', cell:['Extra','" . $row ['Extra'] . "']}" . NL;
                    echo "]" . NL;
                }
            }
        }
        echo "}" . NL;
    } else {
        ?>
        {
            page:1,
            total:1,
            rows:[
            ]
        }
        <?php
    }

    require_once ('inc/generic_finish.inc');
?>
Return current item: AJAX MySQL Admin