-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserDataLoad.php
More file actions
54 lines (32 loc) · 1.26 KB
/
userDataLoad.php
File metadata and controls
54 lines (32 loc) · 1.26 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require 'connection.php';
if(isset($_GET["userId"])){
$userId = $_GET["userId"];
$userDataTable = Database::search("SELECT * FROM `user` INNER JOIN `country` ON `user`.`country_id_id`=`country`.`country_id` WHERE `id`='".$userId."'");
$userDataTableRow = $userDataTable->fetch_assoc();
$userDataArray = array();
$userData = new stdClass();
$userData->name = $userDataTableRow["fname"]." ".$userDataTableRow["lname"];
$userData->about = $userDataTableRow["about"];
$userData->mobile = $userDataTableRow["mobile"];
$userData->email = $userDataTableRow["email"];
$userData->country = $userDataTableRow["name"];
array_push($userDataArray,$userData);
$userDataJsonObj = json_encode($userDataArray);
echo($userDataJsonObj);
}else{
$id = $_GET['id'];
$array = array();
$object = new stdClass();
//response data
$userTable = Database::search("SELECT * FROM `user` WHERE `id`='".$id."'");
$userTableRow = $userTable->fetch_assoc();
$object->pic = $userTableRow["profile_url"];
$object->fname = $userTableRow["fname"];
$object->lname = $userTableRow["lname"];
$object->mobile = $userTableRow["mobile"];
$object->about = $userTableRow["about"];
array_push($array,$object);
$jsonResponse = json_encode($array);
echo($jsonResponse);
}