im having real truble with this php code:
<?php
$sessionid = $_SESSION['id'];
echo $sessionid;
$sql = "SELECT * FROM users WHERE id = '$sessionid';";
$rsults = mysqli_query($conn, $sql);
$resultsCheck = mysqli_num_rows($rsults);
if ($resultsCheck > 0) {
while ($row = mysqli_fetch_assoc($rsults)){
$follow = $row['follow'];
$loc = $row['places'];
echo $follow;
echo $loc;
}
}
$sql = "SELECT * FROM posts WHERE username LIKE '$follow'";
$rsults = mysqli_query($conn, $sql);
$resultsCheck = mysqli_num_rows($rsults);
if ($resultsCheck > 0) {
while ($row = mysqli_fetch_assoc($rsults)){
echo '<div class="posts">';
echo '<img class="img"src='.$row['img'].' width="1500px">';
echo '</div>';
echo '<div class="contain">';
echo '<div class="over">';
echo '<div class="username2">';
echo '<img src="focus.png" width="25px" height="25px" style="padding-right: 10px;">'.'<a href="./Profile.php?data='.$row['username'].'">'.$row['username'].'</a>'.'<img src="loc.png" width="25px" height="25px" style="padding-right: 5px; padding-left: 10px;">'.'<a href="./Location.php?data='.$row['ext'].'">'.$row['ext'].'</a>';
echo '</div>';
echo '<div class="content">';
echo $row['content'];
echo '</div>';
echo '</div>';
}
}else {
echo "There are no results matching your search!";
}
?>
It will output the variables from the first select statement but the second statement only outputs "There are no results matching your search!". I have tried the statement with the actual words (not variables) in php my admin and it works well however when it is on the site..... nothing. I guess its something to do with the variables, but really i have no idea so any help will be appreciated! Thanks so much (and i know variables are open to sql injection but this site is just a proof of concept :)