I'm trying to create a page that lists some notifications according to the user id.
I have this Javascript function to get the results as JSON
var url="http://localhost/app/demo/getNotifications.php";
$$.getJSON(url, function (result) {
$$.each(result, function (i, field) {
var nID = field.id;
var nDonor = field.donor_id;
// APPENDS DATA TO LISTFVIEW
$$("#notlistview").append("HTML HERE");
});
});
And this is the php file:
<?php
include "db1.php";
$USERID = " ";
$data=array();
$q=mysqli_query($con,"SELECT * FROM blood_donations WHERE requester_id='USERID' ORDER BY `id` DESC");
while ($row=mysqli_fetch_object($q)){
$data[]=$row;
}
echo json_encode($data);
?>
My question is how do I pass a value from javascript to fill in the $USERID in the php file with the sent Value?
I only need to retrieve the results related to the USERID, so if you have another way, that's fine too.