mirror of
https://github.com/caperren/school_archives.git
synced 2025-11-09 21:51:15 +00:00
Added work from my other class repositories before deletion
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?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_skills 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($skill_name, $skill_description);
|
||||
|
||||
while($entry = $db_query->fetch()){
|
||||
$resp_arr['skills'][] = array($skill_name, $skill_description);
|
||||
}
|
||||
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user