Query: mysqli_fetch_row
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
MYSQLI_FETCH_ROW(3) 1 MYSQLI_FETCH_ROW(3) mysqli_result::fetch_row - Get a result row as an enumerated array Object oriented styleSYNOPSISmixed mysqli_result::fetch_row (void )DESCRIPTIONProcedural style mixed mysqli_fetch_row (mysqli_result $result) Fetches one row of data from the result set and returns it as an enumerated array, where each column is stored in an array offset starting from 0 (zero). Each subsequent call to this function will return the next row within the result set, or NULL if there are no more rows.PARAMETERSo $ result -Procedural style only: A result set identifier returned by mysqli_query(3), mysqli_store_result(3) or mysqli_use_result(3).RETURN VALUESmysqli_fetch_row(3) returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in result set. Note This function sets NULL fields to the PHP NULL value.EXAMPLESExample #1 Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5"; if ($result = $mysqli->query($query)) { /* fetch object array */ while ($row = $result->fetch_row()) { printf ("%s (%s) ", $row[0], $row[1]); } /* free result set */ $result->close(); } /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5"; if ($result = mysqli_query($link, $query)) { /* fetch associative array */ while ($row = mysqli_fetch_row($result)) { printf ("%s (%s) ", $row[0], $row[1]); } /* free result set */ mysqli_free_result($result); } /* close connection */ mysqli_close($link); ?> The above examples will output: Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA)SEE ALSOmysqli_fetch_array(3), mysqli_fetch_assoc(3), mysqli_fetch_object(3), mysqli_query(3), mysqli_data_seek(3). PHP Documentation Group MYSQLI_FETCH_ROW(3)
Related Man Pages |
---|
mysqli_select_db(3) - php |
mysqli_result.fetch_assoc(3) - php |
mysqli_num_fields(3) - php |
mysqli_multi_query(3) - php |
mysqli_warning_count(3) - php |
Similar Topics in the Unix Linux Community |
---|
Simple rules of the UNIX.COM forums: |
UNIX.COM 2017 Year End Summary |
Status of UNIX.COM Forum Transformation |
Please Welcome Ravinder Singh to the Moderation Team |
Denial Of Service Attack Update |