<?php
$db = mysqli_connect('localhost', 'root', '', 'opony');
$query = "SELECT id_zam, ilosc, model, cena FROM zamowienie JOIN opony USING(nr_kat) ORDER BY RAND() LIMIT 1;";

$result = mysqli_query($db, $query);
while ($row = mysqli_fetch_assoc($result)) {
    echo $row['id_zam'] . " - " . $row['ilosc'] . " - " . $row['model'] . " - " . $row['cena'] . "<br>";
}
mysqli_close($db);