I want to select only posts where authorId is only 1 and 2. And i do that like this:
$array = [1,2];
$array = implode(", ",$array);
$sql = "SELECT * FROM post WHERE authorId = ({$array})";
$res = $con->query($sql);
while($row = $res->fetch_assoc()){
echo $row['firstname'] . ' ' . $row['lastname'];
}
I got error message:
Fatal error: Call to a member function fetch_assoc() on boolean in C:\xampp\blablaba.php on line blablaba
But when i try to get posts just from one author i dont get any error message. Actually it works, here is my code for one authorId:
$sql = "SELECT * FROM post WHERE authorId = 1)";
$res = $con->query($sql);
while($row = $res->fetch_assoc()){
echo $row['firstname'] . ' ' . $row['lastname'];
}