<?php
  require_once 'login.php';
  $conn = new mysqli($hn, $un, $pw, $db);
  if ($conn->connect_error) die($conn->connect_error);

  $query  = "SELECT * FROM customers";
  $result = $conn->query($query);
  if (!$result) die ("Brak dostêpu do bazy danych: " . $conn->error);

  $rows = $result->num_rows;

  for ($j = 0 ; $j < $rows ; ++$j)
  {
    $result->data_seek($j);
    $row = $result->fetch_array(MYSQLI_NUM);
    echo "$row[0] zakupi³(a) ISBN $row[1]:<br>";

    $subquery  = "SELECT * FROM classics WHERE isbn='$row[1]'";
    $subresult = $conn->query($subquery);
    if (!$subresult) die ("Brak dostêpu do bazy danych: " . $conn->error);

    $subrow = $subresult->fetch_array(MYSQLI_NUM);
    echo "  '$subrow[1]' autora $subrow[0]<br>";
  }
?>
