Skip to content
Snippets Groups Projects
Commit 992535a8 authored by Aldrich Valentino Halim's avatar Aldrich Valentino Halim
Browse files

added preferred location view list

parent 823250d6
1 merge request!42Projekers - 13515051 - Girvandi Ilyas
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
/* Model */ /* Model */
include "../model/user.php"; include "../model/user.php";
//TODO: tambahin redirect klo get kosong
$user = new User; $user = new User;
$user_id = $_GET['id']; $user_id = $_GET['id'];
$result = $user->getUserById($user_id); $result = $user->getUserById($user_id);
$locations = $user->getPreferredLocation($user_id);
header('Content-Type: text/xml'); header('Content-Type: text/xml');
$xml = '<user>'; $xml = '<user>';
while($row = mysqli_fetch_array($result)){ while($row = mysqli_fetch_array($result)){
...@@ -15,6 +14,9 @@ while($row = mysqli_fetch_array($result)){ ...@@ -15,6 +14,9 @@ while($row = mysqli_fetch_array($result)){
'</username><email>' . $row['email'] . '</email><image>' . $row['image'] . '</username><email>' . $row['email'] . '</email><image>' . $row['image'] .
'</image><phone>' . $row['phone'] . '</phone><driver>' . $row['isDriver'] . '</driver>'; '</image><phone>' . $row['phone'] . '</phone><driver>' . $row['isDriver'] . '</driver>';
} }
while($row = mysqli_fetch_array($locations)){
$xml = $xml . '<location>'. $row['location'] .'</location>';
}
$xml = $xml . '</user>'; $xml = $xml . '</user>';
print $xml; print $xml;
......
...@@ -122,4 +122,8 @@ ...@@ -122,4 +122,8 @@
#email, #phone { #email, #phone {
font-size: 1.5rem; font-size: 1.5rem;
display: inline-block; display: inline-block;
}
#user-location li {
font-size: 1.2rem;
margin-bottom: 5px;
} }
\ No newline at end of file
...@@ -8,7 +8,8 @@ function getUserProfile(){ ...@@ -8,7 +8,8 @@ function getUserProfile(){
var name = result.getElementsByTagName('name')[0].childNodes[0].nodeValue; var name = result.getElementsByTagName('name')[0].childNodes[0].nodeValue;
var email = result.getElementsByTagName('email')[0].childNodes[0].nodeValue; var email = result.getElementsByTagName('email')[0].childNodes[0].nodeValue;
var phone = result.getElementsByTagName('phone')[0].childNodes[0].nodeValue; var phone = result.getElementsByTagName('phone')[0].childNodes[0].nodeValue;
var image =result.getElementsByTagName('image')[0].childNodes[0].nodeValue; var image = result.getElementsByTagName('image')[0].childNodes[0].nodeValue;
var arrayLocation = result.getElementsByTagName('location');
document.getElementById('username').innerHTML = 'Hello, ' + name + '!'; document.getElementById('username').innerHTML = 'Hello, ' + name + '!';
document.getElementById('profile-username').innerHTML = '@' + username; document.getElementById('profile-username').innerHTML = '@' + username;
...@@ -16,6 +17,18 @@ function getUserProfile(){ ...@@ -16,6 +17,18 @@ function getUserProfile(){
document.getElementById('email').innerHTML = email; document.getElementById('email').innerHTML = email;
document.getElementById('phone').innerHTML = phone; document.getElementById('phone').innerHTML = phone;
document.getElementById('user-image').style.backgroundImage = 'url(../img/' + image + ')'; document.getElementById('user-image').style.backgroundImage = 'url(../img/' + image + ')';
var listOfLocation = document.getElementById('user-location');
console.log(listOfLocation.childElementCount);
while(listOfLocation.hasChildNodes()){
listOfLocation.removeChild(listOfLocation.lastChild);
}
for(i = 0; i < arrayLocation.length; i++){
var loc = arrayLocation[i].firstChild.nodeValue;
var singleList = document.createElement('li');
singleList.style.marginLeft = i*20;
singleList.innerHTML = loc;
listOfLocation.appendChild(singleList);
}
} }
}; };
xmlhttp.open('GET', '../controller/profile.php?id=' + id, true); xmlhttp.open('GET', '../controller/profile.php?id=' + id, true);
......
...@@ -91,4 +91,12 @@ class User { ...@@ -91,4 +91,12 @@ class User {
mysqli_close($con); mysqli_close($con);
return $result; return $result;
} }
function getPreferredLocation($id){
$con = mysqli_connect('localhost','root','','projekers');
mysqli_select_db($con,'projekers');
$query = "SELECT location FROM pref_loc WHERE id=" . $id;
$result = mysqli_query($con,$query);
mysqli_close($con);
return $result;
}
} }
\ No newline at end of file
...@@ -49,7 +49,9 @@ ...@@ -49,7 +49,9 @@
<section class="profile-wrapper"> <section class="profile-wrapper">
<div class="sub-header"> <div class="sub-header">
<div class="sub-header-heading"><h1>MY PROFILE</h1></div> <div class="sub-header-heading"><h1>MY PROFILE</h1></div>
<div class="edit-icon"><img src="../img/pencil.png" /></div> <div class="edit-icon">
<a href="../view/edit-profile.php?id=<?php echo $_GET['id'] ?>"><img src="../img/pencil.png" /></a>
</div>
</div> </div>
<div class="user-profile"> <div class="user-profile">
<div id="user-image"></div> <div id="user-image"></div>
...@@ -61,15 +63,11 @@ ...@@ -61,15 +63,11 @@
</div> </div>
<div class="sub-header"> <div class="sub-header">
<div class="sub-header-heading"><h1>PREFERRED LOCATION</h1></div> <div class="sub-header-heading"><h1>PREFERRED LOCATION</h1></div>
<div class="edit-icon"><img src="../img/pencil.png" /></div> <div class="edit-icon">
</div> <a href="../"><img src="../img/pencil.png" />
<div class="user-location"> </div>
<ul type="square" id="user-location">
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
</div> </div>
<div class="user-location"><ul id="user-location"></ul></div>
</section> </section>
</div> </div>
</body> </body>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment