-1
我有几个项目一NG重复列表中,我以.json看起来是这样的:AngularJS在PHP函数PHP NG重复串
[
{
"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": ""
}
]
,我有我的NG-重复这里面的PHP:
<?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
?>
喜欢()PHP函数如下:
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;
}
我 '喜欢' 表:
1 id Primary Key int(12)
2 item_id int(12)
我总是得到0作为likes()的结果。不知道我是否需要整数或字符串。我也尝试过“id”:1。
我想为每个帖子显示正确的喜欢量。
在此先感谢:)