You are here: Re: Retrieving fields name from mysql « PHP Programming Language « IT news, forums, messages
Re: Retrieving fields name from mysql

Posted by Mike Youell on 04/10/06 18:38

As far as I'm aware there is no way to do it accept use the "describe"
function of mysql (or sql or whatever).

You can call this using the php mysql query command. I use mysqli in
PHP5, it becomes even easier then.

I haven't tested this but try the following:

// Initialise the type array to empty.
$TypeArray = array();

// Perform the mysql "describe" of the table Categories.
$QueryResult = $this->m_mysqli->query("describe Categories");

// Error checking for above function here, yada yada yada ;o)

// Convert the first result into an object.
$ResultObject = $QueryResult->fetch_object();

// If there was a result then...
while ($ResultObject !== NULL)
{
// Get the type...
$Type = $ResultObject->Type;

// And push it onto the type array.
array_push($TypeArray, $Type);

// Get the next result.
$ResultObject = $QueryResult->fetch_object();
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация