mirror of
https://github.com/caperren/school_archives.git
synced 2025-11-09 21:51:15 +00:00
44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
include '../db_creds.php';
|
|
ini_set('display_errors', 'On');
|
|
|
|
$robo_db = new mysqli($db_host, $db_user, $db_pass, $db_name);
|
|
$resp_arr = array();
|
|
|
|
if($robo_db->connect_errno){
|
|
$resp_arr['is_error'] = true;
|
|
$resp_arr['error_reason'] = "Failed to connect to database!";
|
|
echo json_encode($resp_arr);
|
|
return;
|
|
}else{
|
|
$db_query = $robo_db->prepare(<<<QUERY_STRING
|
|
|
|
SELECT name, description from club_teams GROUP BY id ASC
|
|
|
|
QUERY_STRING
|
|
);
|
|
|
|
$db_query->execute();
|
|
|
|
if(!$db_query){
|
|
$resp_arr['is_error'] = true;
|
|
$resp_arr['error_reason'] = "Database query failed!";
|
|
$resp_arr['mysqli_errno'] = $db_query->errno;
|
|
$resp_arr['mysqli_error'] = $db_query->error;
|
|
echo json_encode($resp_arr);
|
|
return;
|
|
}else{
|
|
$resp_arr['is_error'] = false;
|
|
|
|
$db_query->bind_result($team_name, $team_description);
|
|
|
|
while($entry = $db_query->fetch()){
|
|
$resp_arr['teams'][] = array($team_name, $team_description);
|
|
}
|
|
|
|
echo json_encode($resp_arr);
|
|
}
|
|
}
|
|
|
|
|