RE: output the schema

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

 



<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:ross@xxxxxxxxxxxxxx] 
Sent: Friday, August 03, 2007 6:09 AM
To: php-general@xxxxxxxxxxxxx
Subject:  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


[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