EasyPHPScripts.com      Free Open Source PHP Scripts and Code Snippet Library

 +Menu
+   Site News
+   Main Pages
+   Other Downloads
 +PHP
+ Arrays (9)
+ Directory And Files (7)
+ Image (3)
+ LDAP (3)
+ MySQL (11)
+ Basic MySQL Example
+ Database Information
+ Error Checking
+ Fetch Associative Array
+ Last Insert ID
+ Number of Rows
+ Record Paging
+ SQL Dump to Database
+ Select Examples
+ Table and Field Information
+ Various Information
+ Other (11)
+ Regular Expressions (3)
+ String Manipulation (13)
+ Time and Date (6)
 +Snippet Options
+   Printer Friendly
 +Library Options
+   View Other Library
 +General Options
+   Log in
Description for Snippet: MySQL / Table and Field Information
  Print out table and field information
 
Syntax for: Table and Field Information

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
<?php
    mysql_connect
("localhost""mysql_username""mysql_password");
    
mysql_select_db("mysql");
    
$result mysql_query("SELECT * FROM func");
    
$fields mysql_num_fields($result);
    
$rows   mysql_num_rows($result);
    
$table mysql_field_table($result0);
    echo 
"Your '".$table."' table has ".$fields." fields and ".$rows." record(s)n";
    echo 
"The table has the following fields:n";
    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";
    }
    
mysql_free_result($result);
    
mysql_close();
?>
 


 
Powered by: PHP & centOS