Re: Collecting info about columns in a table

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

 



Afan,

Here's some code that will show enum values:


$q2 = "describe ". $tname . " ;";
$r2 = mysql_query($q2) or die(mysql_error());
while ( $a2 = mysql_fetch_array($r2) )
{
	$els = count($a2);
	echo "<br>";
	for ($i2 = 0; $i2 < $els; $i2++)
	{
		$f = $a2[$i2] ;
		if ($f == "") $f = "&nbsp;";
		echo $f . " | ";
	}
	echo "\n";
}

Perhaps combining it with your code will give you what you need.

Gerry

On 1/29/06, Afan Pasalic <afan@xxxxxxxx> wrote:
> Hi to all,
> I need to collect info about columns from a selected table.
> I use this:
>
> $result = mysql_query("SELECT * FROM ". $TableName);
> $fields = mysql_num_fields($result);
> 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 $type . " | " . $name . " | " . $len . " | " . $flags ."\n";
> }
>
> If I have columns type ENUM('live', 'hidden', 'pending'), $flags will show
> ONLY 'enum'.
> How can I get all ENUM values?
>
> Thanks for any help or direction.
>
> -afan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Gerry
http://portal.danen.org/

-- 
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