Search DaTutorials:  
HOME
Php Tutorials
Articles
Basics
Date and Time
File Manipulations
Forms
Functions
General
Interactivity
MySql
Navigation
News,Shoutboxes and Blogs
Language Structure and Data Types
Searching
Security
String Manipulation
User Information and Stats
Search For a Tutorial
Php Reference

mysql_list_fields

(PHP 3, PHP 4 , PHP 5)

mysql_list_fields -- List MySQL table fields

Description

resource mysql_list_fields ( string database_name, string table_name [, resource link_identifier])

mysql_list_fields() retrieves information about the given table name. Arguments are the database and the table name. A result pointer is returned which can be used with mysql_field_flags(), mysql_field_len(), mysql_field_name(), and mysql_field_type().

Example 1. mysql_list_fields() example

<?php
$link
= mysql_connect('localhost', 'mysql_user', 'mysql_password');

$fields = mysql_list_fields("database1", "table1", $link);
$columns = mysql_num_fields($fields);

for (
$i = 0; $i < $columns; $i++) {
   echo
mysql_field_name($fields, $i) . "\n";
}
?>

The above example would produce the following output:

field1
field2
field3
...

For downward compatibility mysql_listfields() can also be used. This is deprecated however.

Note: The function mysql_list_fields() is deprecated. It is preferable to use mysql_query() to issue a SQL SHOW COLUMNS FROM table [LIKE 'name'] Statement instead.



Copyright © 2001-2004 The PHP Group
All rights reserved.

     Fast Loans | Online Loans | Mortgage | Credit Report | Xbox Mod Chip
Home     Link To Us     Ad With Us     Contact Us     Tell A Friend     Affiliates     Blog     MsOfficeHelp