PHP Doku:: Liefert die Anzahl der Ergebnisspalten - function.odbc-num-fields.html

Verlauf / Chronik / History: (8) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAbstraktionsebenenODBC (Unified)ODBC Funktionenodbc_num_fields

Ein Service von Reinhard Neidl - Webprogrammierung.

ODBC Funktionen

<<odbc_next_result

odbc_num_rows>>

odbc_num_fields

(PHP 4, PHP 5)

odbc_num_fieldsLiefert die Anzahl der Ergebnisspalten

Beschreibung

int odbc_num_fields ( int $result_id )

odbc_num_fields() liefert die Anzahl der Spalten, die in einem ODBC-Ergebnis vorhanden sind, zurück. Bei einem Fehler ergibt odbc_num_fields() -1.


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
udin
2.10.2006 11:31
<?php
$conn
= odbc_connect('MySQL','','');
echo
"Database = " . "MySQL";

$res = odbc_tables($conn);

------------------------------------
Using odbc_num_fields() for showing description of an object table in one database
------------------------------------
while (
odbc_fetch_row($res))
{
   
$jml = odbc_num_fields($res);
    for(
$i=1;$i<=$jml;$i++)
        {
           echo
odbc_field_name($res,$i) . " = " . odbc_result($res,$i);
        }   
   
}

------------------------------------
The 2nd example of using odbc_num_fields(). It retrieves FIELD NAME and FIELD VALUE for each record in CUSTOMER Table
------------------------------------

$sql = 'SELECT * FROM PEGAWAI';
$rs = odbc_exec($conn,$sql);

while (
odbc_fetch_row($rs))
{
     for(
$j=1;$j<=odbc_num_fields($rs);$j++)
         echo
odbc_field_name($rs,$j) . " = " odbc_result($rs,$j) ;

  
}

?>
xdean78@yahoo.com



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)