Example 1 — Rewind the Field Cursor
Read one field, seek back to 0, and read the first field name again from a sample result.
<?php
$mysqli = mysqli_connect("localhost", "demo", "secret", "shop");
$result = mysqli_query($mysqli, "SELECT id, name FROM products LIMIT 1");
mysqli_fetch_field($result);
mysqli_field_seek($result, 0);
$field = mysqli_fetch_field($result);
echo $field->name, PHP_EOL;
mysqli_free_result($result);
mysqli_close($mysqli); How It Works
- The first fetch_field() consumes the id metadata.
- mysqli_field_seek($result, 0) moves back to the start.
- The next fetch_field() returns id again.
- Sample output reprints id.

