Php / MySQL DESC tablename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

First off thanks to everyone for the previous help. I managed to get it
sorted out and used several of the suggestions made.

I am trying to do a DESC table_name using PHP so it looks like it would it
you did it from the command line.

i.e. 

| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| id        | int(11)      | NO   | PRI | NULL    | auto_increment | 
| name      | varchar(30)  | NO   |     | NULL    |                | 

What I have found is that the following does not work the way I would have
thought.

	$query = "DESC table ".$currenttb;
	$result = mysql_query($query);
	
	while ($row = mysql_fetch_row($result)) {
		etc.....

I have found something that works, but it is still not like the above and is
really bulky. I can not get the type (varchar, etc) to show like above, it
will show string, blob, etc, and the last problem is it puts the last 4
fields in one variable (flags).

Does anyone know of a way to get this to output as shown above. I am putting
this into a form for editing, so I need everything in the proper places.

Thanks


Here is the entire code:

	mysql_select_db($_SESSION['currentdb']);
	
	$result = mysql_query("SELECT * FROM ".$_SESSION['currenttb']);
	$fields = mysql_num_fields($result);
	$rows  = mysql_num_rows($result);
	$table  = mysql_field_table($result, 0);
	
	for ($i=0; $i < $fields; $i++) {
		$type  = mysql_field_type($result, $i);
		$name  = mysql_field_name($result, $i);
		$len  = mysql_field_len($result, $i);
		$flags = mysql_field_flags($result, $i);
		echo all the filds....
	}

This outputs (depending on the order you echo them):

username string 50 [not_null primary_key auto_increment]  value in [] is one
value.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux