Bu şekilde bi dener misin hocam.
@elax;
try {
$db = new PDO("mysql:host=localhost;dbname=test", "root", "");
} catch ( PDOException $e ){
print $e->getMessage();
}
$query = $db->prepare("SELECT * FROM tablo_adi");
$query->execute();
$result = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$veri[] =
[
"user_id" => $row["user_id"],
"fullname" => $row["fullname"],
"phonenumber" => $row["phonenumber"],
"cart_items" =>
[
[
"cart_name" => $row["cart_name"],
"quantity" => $row["quantity"]
],
],
];
}
$son = ["items" => $veri];
echo json_encode($son);
hocam çok sağol user tablosunu bu şekil çekebiliyoruz json istediğim gibi geliyor ama iki tablo var ilişkili cart tablosunu araya nasıl çekebilirim?