|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-11-05 16:55 UTC] rasmus at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 16:00:01 2025 UTC |
<?php $host = "localhost"; $user = "nobody"; $database = "varsity"; $password = ""; $conn = mysql_connect($host,$user,$password); $result = mysql_db_query($database,"select * from people"); while ($row = mysql_fetch_row($result)) { for ( $i = 0; $i < mysql_num_fields($result); $i++ ) { $field_info = mysql_fetch_field($result,$i); print "field,len,value = $field_info->name,$field_info->max_length,$row[$i]<BR>"; } } ?> --------------- OUTPUT: field,len,value = person_id,1,1 field,len,value = lname,7,Britton field,len,value = fname,5,Sandi field,len,value = position,3,Mgr --------------- Table Desc from mySQL: +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | person_id | int(11) | | PRI | 0 | auto_increment | | lname | varchar(50) | YES | | NULL | | | fname | varchar(50) | YES | | NULL | | | position | varchar(50) | YES | | NULL | | +-----------+-------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec) mysql>