Új hozzászólás Aktív témák

  • Sk8erPeter

    nagyúr

    válasz Jim-Y #9328 üzenetére

    Ha ilyen van, miért nem kapod elő a php.net leírását?
    "For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error."
    Az adatbázis-kapcsolati erőforrás-azonosítót adja vissza.

    "The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data."

    Ott a példa is:
    // Perform Query
    $result = mysql_query($query);

    // Check result
    // This shows the actual query sent to MySQL, and the error. Useful for debugging.
    if (!$result) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
    }

    // Use result
    // Attempting to print $result won't allow access to information in the resource
    // One of the mysql result functions must be used
    // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
    while ($row = mysql_fetch_assoc($result)) {
    echo $row['firstname'];
    echo $row['lastname'];
    echo $row['address'];
    echo $row['age'];
    }

    =====

    Nálad most csak egy sor lesz, ezért nem kell ciklus:

    ...
    if(!empty($rows)){
    $row = mysql_fetch_assoc($res);
    echo 'The country code is the following: '.$row['country_code'];
    }

    ==============================================

    whited
    (#9329) whited :

    nincs mit!
    Amúgy csak szimpla i-vel Brian. :D

Új hozzászólás Aktív témák