1
所以,我想選擇「註釋」基於「userID」。這就是我所做的如何使用angularjs從localStorage調用「用戶ID」變量到PHP?
使用angular.js調用PHP函數
$scope.dapatkanData = function(){
$http.get(
'../php/displayNotes.php'
).success(function(data){
$scope.notes = data;
});
};
創建displayNotes.php從數據庫中選擇數據,其中localStorage.getItem( 「ID」)
<?php
include('connect.php');
$postdata = file_get_contents(localStorage.getItem('user'));
$dataObjek = json_decode($postdata);
$user = $dataObjek->userID;
$hashtype = "sha256";
$userID = hash($hashType,$user);
$perintah_sql = "select * from notes where notesID='{$userID}'";
$data = [];
$result = mysqli_query($koneksi,$perintah_sql);
while($row = mysqli_fetch_array($result)){
$temp_data = [];
$temp_data['notesID'] = $row['notesID'];
$temp_data['notesNo'] = $row['notesNo'];
$temp_data['notesTitle'] = $row['notesTitle'];
$temp_data['notesContent'] = $row['notesContent'];
$temp_data['notesDate'] = $row['notesDate'];
array_push($data,$temp_data);
}
echo json_encode($data);
?>
但後來我沒有返回任何應用程序後,我不知道我現在應該做什麼...一直在尋找小時,但仍然沒有解決方案
任何想法該怎麼做? –
我也嘗試過在javascript裏面使用localStorage,但是仍然沒有結果.... –
你是否在某處存儲了**用戶**? – Endless