Hi,

I would like to know if there are some PHP functions that can
spit out the table structure for me.


I wrote a script to build my database like this:

PHP Code:
/*
**********  CLIENTS TABLE  *********************
*/
$sql "DROP TABLE IF EXISTS `clients`";
$result mysql_query($sql)
    or die(
"could not DROP clients."mysql_error());  

echo 
"DROPPED clients Table <br>";

$sql "CREATE TABLE `clients` (
    `client_id` smallint(6) unsigned NOT NULL auto_increment,
    `agent_no` smallint(6) NOT NULL default 0,
    `live` char(1)  NOT NULL default 'n',

    ... and lots more

     KEY `email` (`email`),
     PRIMARY KEY (client_id)

) ENGINE=MyISAM DEFAULT CHARSET=latin1"
;


$result mysql_query($sql)
    or die(
"could not CREATE clients."mysql_error());  

echo 
"Created clients Table <br> date:$today_time<br>";

// ADD DATA using:

$sql "INSERT INTO `clients` (confirm,type,access,profile,lig_pos,contact,client_pict,email,create_date,last_date)
        VALUES 
        ('y','P','zxc345A','This is the Visitor profile','900','Visitor','dave.jpg ','Dave@test.com','
$today_time','$today_time'),
        ('y','P','pass003','This is my Expert profile ','894','John Simmons','john.jpg','John@test.com','
$today_time','$today_time'),
        ('y','m','rg007','This is a member profile','101','Rosalind Gardner','rosalind.jpg','rosalind@test.com','
$today_time','$today_time')";

$result mysql_query($sql)
         or die(
"could not execute INSERT set up clients."mysql_error());  

echo 
"FILLED clients Table <br>"
And then I do the same for other tables.

Now since I initially created the tables,
I have added new columns and changed some of the existing ones.

Is there an easy way to output current table structures
so that I can easily insert it in to my build_tables.php script ?

Also how can I dump the current rows of data so that I can
add them to the build_tables.php script and rebuild my table if I want/need it ?

PS - I don't want to load a php class or package of any kind
I would just like to use PHP commands / functions and my own scripts.

Thanks.


.