Example 1 — Read One Numeric Row
Fetch a single row and print columns by index from a fixed sample.
<?php
$mysqli = mysqli_connect("localhost", "demo", "secret", "shop");
$result = mysqli_query($mysqli, "SELECT id, name FROM products WHERE id = 1");
$row = mysqli_fetch_row($result);
echo $row[0], " ", $row[1], PHP_EOL;
mysqli_free_result($result);
mysqli_close($mysqli); How It Works
- The SELECT returns id then name.
- mysqli_fetch_row() stores them at indexes 0 and 1.
- We print both values with a space between.
- Sample output shows the first demo product.

