Re: Looping through the mysql_field_name function

From: Date: Mon, 03 Feb 2003 21:57:50 +0000
Subject: Re: Looping through the mysql_field_name function
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-18339@lists.php.net to get a copy of this message
Thanks Cam, That was what i was trying to figure out.... i just didnt see it Best regards, Davy Obdam mailto:info@davyobdam.com Cam Dunstan wrote:
Davy put this into a script and run it .......
$dbase = "somedatabase";    // change this to suit   !!
$db = mysql_connect("localhost", "root");       // change this also!!
mysql_select_db($dbase,$db); $result = mysql_list_tables($dbase); $rowcount = mysql_num_rows($result); for ($j = 0; $j < $rowcount; $j++){ $tablenam = mysql_tablename($result, $j); echo "<strong>".$tablenam."</strong> ("; $fieldresult = mysql_list_fields($dbase, $tablenam); $fieldcount = mysql_num_fields($fieldresult); echo $fieldcount." fields)<br>\n"; for ($k = 0; $k < $fieldcount; $k++){ $fieldnam = mysql_field_name($fieldresult, $k); echo "&nbsp;&nbsp;&nbsp;".$fieldnam."&nbsp;&nbsp;<small>"; $fieldtyp = mysql_field_type($fieldresult, $k); echo $fieldtyp." ("; $fieldsiz = mysql_field_len($fieldresult, $k); echo $fieldsiz.") </small><br>\n"; } echo "<hr>\n"; } that should tell you everything you need to know about your database and how to do it. ----- Original Message ----- From: "Davy Obdam" <info@davyobdam.com> To: "PHP-WIN" <php-windows@lists.php.net>; "PHP" <php-general@lists.php.net> Sent: Monday, February 03, 2003 5:24 AM Subject: [PHP-WIN] Looping through the mysql_field_name function
Hi ppl, I have a problem that probably very simple, but i cannot figure it out right now.... I need to get the field names of my database. I have a query like select * from books and now i wanna have both the result and the field name. I have been trying with mysql_field_name, but not succesfully... $i = 0; for($a=0; $a < sizeof(mysql_field_name($db->sqlResult, $i)); $a++) { echo mysql_field_name($db->sqlResult, $i)."<br />"; $i++; } Can anyone help me please.. Your help is greatly appreciated;-) Best regards, Davy Obdam mailto:info@davyobdam.com -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- -------------------------------------------------------------------- Davy Obdam - Obdam webdesign© mailto:info@davyobdam.com web: www.davyobdam.com --------------------------------------------------------------------

« previous php.windows (#18339) next »