<?php
require("db.php");
session_start();
$id = $_SESSION["id"];
$sql = "SELECT seguido FROM seguindo WHERE seguidor = '$id'";
$result = $conn->query($sql) or die($conn->error);
$posts = array();
while($row = $result->fetch_assoc()){
print_r($row);
$id_seguindo = $row["seguido"];
$sql = "SELECT imagem, descricao, tempo FROM posts WHERE id = '$id_seguindo' OR id='$id' ORDER BY tempo DESC";
$result = $conn->query($sql) or die($conn->error);
$row = $result->fetch_assoc();
$posts[] = array(
"imagem" => $row["imagem"],
"descricao" => $row["descricao"],
"tempo" => $row["tempo"]
);
}
foreach($posts as $post){
echo "<div class='post'>";
echo "<img src='" . $post["imagem"] . "'>";
echo "<p>" . $post["descricao"] . "</p>";
echo "<p>" . $post["tempo"] . "</p>";
echo "</div>";
}
?>
For some reason, the while has become infinite and it is noticing that the "seguido" index is not defined. I don't know why this is happening and I've tried both the "isset" function and "print_r" to debug, but it didn't work.