diff --git a/api/fetch-all-plants.php b/api/fetch-all-plants.php new file mode 100644 index 0000000..bb86250 --- /dev/null +++ b/api/fetch-all-plants.php @@ -0,0 +1,11 @@ +fetchAllPlants(); + +echo json_encode($all_plants); \ No newline at end of file diff --git a/classes/Plant.php b/classes/Plant.php index 61adf74..defd568 100644 --- a/classes/Plant.php +++ b/classes/Plant.php @@ -22,7 +22,8 @@ public function fetchAllPlants(): array FROM `plants` LEFT JOIN `types_of_plant` ON `plants`.`plant_type` = `types_of_plant`.`id` - WHERE `plants`.`deleted`="0"' + WHERE `plants`.`deleted`="0" + ORDER BY `plants`.`id` DESC;' ); $query->execute(); @@ -56,7 +57,11 @@ public function addPlantType($plantType): void "INSERT INTO `types_of_plant` (`plant_type`) VALUES (?);" ); - $query->execute($plantType); + $params = [ + $plantType + ]; + + $query->execute($params); } public function addNewPlant($plantType, $plantCultivar, $datePlanted, $projectedHarvest, $imgURL): void diff --git a/components/navbar.php b/components/navbar.php index 7b33a43..4bcdb25 100644 --- a/components/navbar.php +++ b/components/navbar.php @@ -1,6 +1,6 @@