I have a ng-repeat list with several items, my .json looks like this:
[
{
"id": "1",
"title": "Lab #3",
"desc": "iOS App Design.",
"img": "https://lorempixel.com/774/600/sports/",
"tags": "App | Nav | Design"
},
{
"id": "2",
"title": "Lab #2",
"desc": "iOS app.",
"img": "https://lorempixel.com/774/600/abstract/",
"tags": "App | Design"
},
{
"id": "3",
"title": "Lab #1",
"desc": "Logo für dprecht",
"img": "img/lab/labor-1.jpg",
"tags": "Logo | Rot | Design",
"href": ""
}
]
and i have this php inside my ng-repeat:
<?php
echo "{{::lab.id}}"; // 1, 2, 3
$itemid_string = "{{::lab.id}}";
$itemid_int = intval($itemid_string);
var_dump($itemid_string); // string(12) "1"
var_dump($itemid_int); // int(0)
echo likes($itemid_string); // or with $itemid_int
?>
the likes() php function looks like this:
function likes($item_id) {
global $con;
$query = mysqli_query($con, "SELECT * FROM likes WHERE item_id='$item_id'");
$likes = mysqli_num_rows($query);
return $likes;
}
my 'likes' table:
1 id Primary Key int(12)
2 item_id int(12)
I always get 0 as the result of likes(). not sure if i need integer or a string. i tried "id": 1, in the .json too.
i want to display the correct amount of likes for every post.
Thanks in advance :)