我试图从 mysql 表中找出我所有的“喜欢”并将它们放入一个数组中,但我真的不确定我是否做得对,因为我不断收到“错误的数据类型”错误。这是我的代码:
<?php
$check_like_sql = "SELECT * FROM posts WHERE type = 'Like' && poster = '$yourid'";
$check_like_res = mysqli_query($con, $check_like_sql) or die (mysqli_error());
if(mysqli_affected_rows($con)>0){
while($likes = mysqli_fetch_assoc($check_like_res)){
$yourlike = $likes['media'];
}
$likearray = mysqli_fetch_array($con, $yourlike);
}
?>
<?php
if(in_array($likearray, $postid)) {
$likethis = "<a href=\"php/unlike.php?poster=$yourid&post=$postid\">Unlike</a> . ";
}
else if($posttype == "Like"){
$likethis = "";
}
else{
$likethis = "<a href=\"php/like.php?poster=$yourid&lat=$yourlat&lon=$yourlon&like=$postid&user=$postusername\">Like</a> . ";
}
?>
谁能解释一下哪里可能有错误?我对这种 php 编码很陌生。谢谢