Forum und email

mysql_num_fields

(PHP 4, PHP 5, PECL mysql:1.0)

mysql_num_fields — Get number of fields in result

Popis

int mysql_num_fields ( resource $result )

Retrieves the number of fields from a query.

Parametre

result

Výsledný resource, ktorý je vyhodnocovaný. Tento výsledok pochádza z volania mysql_query().

Vrátené hodnoty

Returns the number of fields in the result set resource on success, or FALSE on failure.

Príklady

Example#1 A mysql_num_fields() example

<?php
$result 
mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!
$result) {
    echo 
'Could not run query: ' mysql_error();
    exit;
}

/* returns 2 because id,email === two fields */
echo mysql_num_fields($result);
?>

Poznámky

Note: Pre spätný kompatibilitu, nasledujúci zastaraný alias môže byť použitý: mysql_numfields()