问题如下。我有两个表用户和卡。当用户有两张或更多卡时,如何编写循环函数?示例:用户 bane 有卡片 222222 和 454545。但是,当我向搜索字段发送问题时,它只抛出第一张卡片。
<?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']; ?>
https://i.stack.imgur.com/0VvXF.jpg
繁花不似锦
HUWWW