-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers_read.php
More file actions
40 lines (30 loc) · 834 Bytes
/
Copy pathusers_read.php
File metadata and controls
40 lines (30 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// Set the JSON header
//header("Content-type: text/json");
$username = "Kevin";
$password = "Flipper1679$";
$database = "makeohio";
mysql_connect(localhost, $username, $password);
@mysql_select_db($database) or die("Unable to find database");
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'pullAll' : pullAll();break;
case 'pullOne' : pullone();break;
}
}
function pullAll(){
$query = "SELECT * FROM users";
$resultsRaw = mysql_query($query);
while($row = mysql_fetch_array($resultsRaw, MYSQL_ASSOC)){
$results[] = $row;
}
echo json_encode($results);
}
function pullOne(){
$id = $_POST['user_id'];
$query = "SELECT * FROM users WHERE user_id ="+$id;
$result = mysql_query($query);
return json_encode($result);
}
?>