note 68431 deleted from function.mysql-field-name by nlopess

From: Date: Tue, 09 Jan 2007 18:40:03 +0000
Subject: note 68431 deleted from function.mysql-field-name by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121500@lists.php.net to get a copy of this message
Note Submitter: jamesl at si-usa dot com ---- i figured this little diddy, if you are trying to get all the field names from your table, but don't feel like doing all that typing. here is this little snippit. you just have to know what your field names are to call them $query = "SELECT * FROM your_table"; $results = mysql_query($query); $numberfields = mysql_num_fields($results); $row = mysql_fetch_object($results); for ($i=0; $i<$numberfields ; $i++ ) { $var = mysql_field_name($results, $i); $$var = $row->$var; } echo $fieldname; cheers. James

« previous php.notes (#121500) next »