<?php if (isset($data)){?> //$data is the API response <div class="card text-center" style="margin:auto; width:50%; margin-top:100px; min-height:200px"> <div class="card-header"> <?php foreach ($data["items"] as $item){ echo "". "food name: ". $item['name'] . "<br>"; $name=$item['name'];} ?> </div> <div class="card-body"> <p class="card-text"> <?php foreach ($data["items"] as $item) { echo "Serving size: " . $item["serving_size_g"] . " gram <br>"; echo "Calories: ". $item["calories"] . "<br>"; echo "Protein: ". $item["protein_g"] . " gram <br>"; echo "Carbohydrates: ". $item["carbohydrates_total_g"] . " gram <br>"; echo "Fat: ". $item["fat_total_g"] . " gram <br>"; } $name=$data['items'][0]['name']; ?></p> <button><a href="addfood.php?name=<?=$name?>">Add Food</a></button> </div> <div class="card-footer text-muted"> </div> <?php } ?> </div> </body> </html>`
GET
<form>
POST
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)