<assuming name="database" value="MySQL" NOT SPECIFIED>

You would probably want to use the combination of the MySQL query "SHOW
COLUMNS FROM <tablename>" and the PHP function mysql_field_type().

An example would be:

<?
        //Establish connection and select database here

        $sql = "SHOW COLUMNS FROM myTable";
        $result = @mysql_query($sql, <connection>) or die();
        //Dummy variable for incrementing current field
        $count = 0;     

        while($row = mysql_fetch_row($result)
        {
                echo "Field:  ".$row[0]."   Type:
".mysql_field_type($result,$count);
                $count++;
        }
?>

Further information and example usage of mysql_field_type() can be found at:
http://us3.php.net/mysql_field_type
Additionally, that site's sidebar lists other useful MySQL functions in PHP.

</assuming>


-- N/A

-----Original Message-----
From: Hulf [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 03, 2007 6:09 AM
To: php-general@lists.php.net
Subject: [PHP] output the schema 

Hi,

I reword my last post.

I want to take the result and generate the field info to the screen e.g


id, int(10)
name, varchar(30)
age, varchar(30). 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to