I'm working on a PHP project the teacher gave us, basically we have to make a website dynamic and create a liste.php with tasks stored in an API the teacher has.
So I have the index.php with the front page on it and the list of all the projects going on ( like trip preparation, shopping list and appartment decoration ). I created a liste.php with all the tasks contained in each project ( buying tickets, booking the hotel and buying a postcard for the trip preparation ).
Now I have to get all the tasks of each project from the API he gave us.
Here's the API
http://todo_api.xx.firstname-lastname.com/tache.php?liste_id=1
That's the API for project n°1, there are 3 projects in total ( I mentionned them all above )
I also have a functions.php with the $api_url stored, and 2 functions, one getting the list of projects, the other getting the tasks for each project.
$api_url = "http://todo_api.xx.firstname-lastname.com/";
function getAllListes(): array {
global $api_url;
$json = file_get_contents($api_url . "liste.php");
return json_decode($json, true);
}
function getAllTaches(): array {
global $api_url;
$json = file_get_contents($api_url . "tache.php?liste_id=" . $id);
return json_decode($json, true);
}
But when I try to print_r that, or even just display each task, I get this :
Notice: Undefined index: liste_id in /Applications/MAMP/htdocs/todo/database/functions.php on line 17
So obviously something is wrong, and this keeps me from going on. Any idea ?
Edit : here's my html/php code regarding the tasklist
$listes = getAllListes();
$taches = getAllTaches($id);
<ul>
<?php foreach ($taches as $tache) : ?>
<li><?php echo $tache["libelle"] ;?></li>
<?php endforeach ; ?>
</ul>
libelle is the index of the information required.
Thanks a lot !