The problem is the following. I have two tables users and cards. How to write a loop function when a user has two or more cards? Example: user bane has cards 222222 and 454545. however, when I send a question to the search field, it only throws out the first card.
<?php
require "connection.php";
$search = $_POST['search'];
$sql = "SELECT users.first_name, users.second_name, cards.card_number
FROM users
INNER JOIN cards
ON cards.user_id = users.id
WHERE cards.card_number = '$search'
OR users.first_name = '$search'
OR users.second_name = '$search'";
$query = mysqli_query($db, $sql);
$result = mysqli_fetch_assoc($query);
echo $result['first_name']." ".$result['second_name']." ",
$result['card_number']; ?>