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,57 @@
|
||||
<?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
|
||||
|
||||
INSERT INTO members(first_name, last_name, position, superior, email, phone, osu_num, rfid_num)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
(SELECT id FROM club_positions cp WHERE cp.name = ?),
|
||||
(SELECT id FROM club_positions cp WHERE cp.name = ?),
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?
|
||||
)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("ssssssii", $_POST['first_name'], $_POST['last_name'], $_POST['position'],
|
||||
$_POST['superior'], $_POST['email'], $_POST['phone'], $_POST['osu_num'], $_POST['rfid_num']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
$resp_arr['affected_rows'] = $db_query->affected_rows;
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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
|
||||
|
||||
INSERT INTO club_positions(name, description) VALUES (?, ?)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("ss", $_POST['name'], $_POST['description']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
$resp_arr['affected_rows'] = $db_query->affected_rows;
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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
|
||||
|
||||
INSERT INTO club_skills(name, description) VALUES (?, ?)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("ss", $_POST['name'], $_POST['description']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
$resp_arr['affected_rows'] = $db_query->affected_rows;
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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
|
||||
|
||||
INSERT INTO club_teams(name, description) VALUES (?, ?)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("ss", $_POST['name'], $_POST['description']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
$resp_arr['affected_rows'] = $db_query->affected_rows;
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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
|
||||
|
||||
INSERT INTO member_skills_relations(member_id, skills_id)
|
||||
VALUES (
|
||||
(SELECT id FROM members m WHERE m.first_name = ? AND m.last_name = ?),
|
||||
(SELECT id from club_skills cs WHERE cs.name = ?)
|
||||
)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("sss", $_POST['first_name'], $_POST['last_name'], $_POST['skill']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
$resp_arr['affected_rows'] = $db_query->affected_rows;
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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
|
||||
|
||||
INSERT INTO member_teams_relations(member_id, team_id)
|
||||
VALUES (
|
||||
(SELECT id FROM members m WHERE m.first_name = ? AND m.last_name = ?),
|
||||
(SELECT id from club_teams ct WHERE ct.name = ?)
|
||||
)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("sss", $_POST['first_name'], $_POST['last_name'], $_POST['team']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
$resp_arr['affected_rows'] = $db_query->affected_rows;
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
include '../db_creds.php';
|
||||
ini_set('display_errors', 'Off');
|
||||
|
||||
$robo_db = new mysqli($db_host, $db_user, $db_pass, $db_name);
|
||||
$resp_arr = array();
|
||||
$affected_rows_total = 0;
|
||||
|
||||
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{
|
||||
########## DELETION FROM MEMBER SKILLS RELATIONS ##########
|
||||
$db_query = $robo_db->prepare(<<<QUERY_STRING
|
||||
|
||||
DELETE FROM member_skills_relations
|
||||
WHERE member_id IN (
|
||||
SELECT id FROM members m
|
||||
WHERE m.first_name = ? AND m.last_name = ?
|
||||
)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("ss", $_POST['first_name'], $_POST['last_name']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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{
|
||||
$affected_rows_total += $db_query->affected_rows;
|
||||
}
|
||||
|
||||
########## DELETION FROM MEMBER TEAMS RELATIONS ##########
|
||||
$db_query = $robo_db->prepare(<<<QUERY_STRING
|
||||
|
||||
DELETE FROM member_teams_relations
|
||||
WHERE member_id IN (
|
||||
SELECT id FROM members m
|
||||
WHERE m.first_name = ? AND m.last_name = ?
|
||||
)
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("ss", $_POST['first_name'], $_POST['last_name']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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{
|
||||
$affected_rows_total += $db_query->affected_rows;
|
||||
}
|
||||
########## DELETION FROM MEMBERS ##########
|
||||
$db_query = $robo_db->prepare(<<<QUERY_STRING
|
||||
|
||||
DELETE FROM members
|
||||
WHERE first_name = ? AND last_name = ?
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("ss", $_POST['first_name'], $_POST['last_name']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
$affected_rows_total += $db_query->affected_rows;
|
||||
$resp_arr['affected_rows'] = $affected_rows_total;
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
include '../db_creds.php';
|
||||
ini_set('display_errors', 'Off');
|
||||
|
||||
$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 m.first_name, m.last_name, cp.name
|
||||
FROM club_positions cp
|
||||
INNER JOIN members m ON m.position = cp.id
|
||||
WHERE cp.name = ?;
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("s", $_POST['name']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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($first_name, $last_name, $position);
|
||||
|
||||
while($entry = $db_query->fetch()){
|
||||
$resp_arr['members'][] = array($first_name, $last_name, $position);
|
||||
}
|
||||
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
include '../db_creds.php';
|
||||
ini_set('display_errors', 'Off');
|
||||
|
||||
$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 om.first_name, om.last_name, cs.name
|
||||
FROM members om
|
||||
INNER JOIN member_skills_relations msr ON om.id = msr.member_id
|
||||
INNER JOIN club_skills cs ON cs.id = msr.skills_id
|
||||
WHERE cs.name = ?
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("s", $_POST['name']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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($first_name, $last_name, $skill);
|
||||
|
||||
while($entry = $db_query->fetch()){
|
||||
$resp_arr['members'][] = array($first_name, $last_name, $skill);
|
||||
}
|
||||
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
include '../db_creds.php';
|
||||
ini_set('display_errors', 'Off');
|
||||
|
||||
$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 om.first_name, om.last_name, ct.name
|
||||
FROM members om
|
||||
INNER JOIN member_teams_relations mtr ON om.id = mtr.member_id
|
||||
INNER JOIN club_teams ct ON ct.id = mtr.team_id
|
||||
WHERE ct.name = ?
|
||||
|
||||
QUERY_STRING
|
||||
);
|
||||
|
||||
$db_query->bind_param("s", $_POST['name']);
|
||||
|
||||
if(!$db_query){
|
||||
$resp_arr['is_error'] = true;
|
||||
$resp_arr['error_reason'] = "Parameter bind failed!";
|
||||
echo json_encode($resp_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
$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($first_name, $last_name, $team);
|
||||
|
||||
while($entry = $db_query->fetch()){
|
||||
$resp_arr['members'][] = array($first_name, $last_name, $team);
|
||||
}
|
||||
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
include '../db_creds.php';
|
||||
ini_set('display_errors', 'Off');
|
||||
|
||||
$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
|
||||
om.first_name,
|
||||
om.last_name,
|
||||
(SELECT name FROM club_positions cp
|
||||
INNER JOIN members m ON m.position = cp.id
|
||||
WHERE m.first_name = om.first_name AND m.last_name = om.last_name),
|
||||
(SELECT name FROM club_positions cp
|
||||
INNER JOIN members m ON m.superior = cp.id
|
||||
WHERE m.first_name = om.first_name AND m.last_name = om.last_name),
|
||||
om.email,
|
||||
om.phone,
|
||||
om.osu_num,
|
||||
om.rfid_num
|
||||
FROM members om;
|
||||
|
||||
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($first_name, $last_name, $position, $superior, $email, $phone, $osu_num, $rfid_num);
|
||||
|
||||
while($entry = $db_query->fetch()){
|
||||
$resp_arr['members'][] = array($first_name, $last_name, $position, $superior, $email, $phone, $osu_num, $rfid_num);
|
||||
}
|
||||
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
include '../db_creds.php';
|
||||
ini_set('display_errors', 'Off');
|
||||
|
||||
$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_positions GROUP BY id DESC
|
||||
|
||||
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($position_name, $position_description);
|
||||
|
||||
while($entry = $db_query->fetch()){
|
||||
$resp_arr['positions'][] = array($position_name, $position_description);
|
||||
}
|
||||
|
||||
echo json_encode($resp_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user