This script retrieves the values of the 'model' column of the 'models' table according to 'make' parameter of the GET request and sends them back as .json response. More...
Variables | |
if (!isset( $_GET[ 'make'])||empty( $_GET[ 'make'])) | |
if(isset($error) && $error==="db_access_failed") | try |
$models = [] | |
while ( $row=$stmt->fetch(PDO::FETCH_ASSOC)) | |
This script retrieves the values of the 'model' column of the 'models' table according to 'make' parameter of the GET request and sends them back as .json response.
$models = [] |
if(!isset($_GET['make'])||empty($_GET['make'])) | ( | ! | isset $_GET[ 'make'])||empty( $_GET[ 'make'] | ) |
Checks if the 'make' parameter is provided in the request. If not, returns an empty JSON array and exits the script.
if (isset( $error) &&$error==="db_access_failed") try |
Checks for a database access error and terminates the script if it occurs.
while($row=$stmt->fetch(PDO::FETCH_ASSOC)) | ( | $row = $stmt->fetch(PDO::FETCH_ASSOC) | ) |
Loops through the query results and collects distinct models into an array. Encodes the collected models as a JSON array and outputs it.