Hello everyone,
I got a problem with my programming, lets take the following scenario:
I got some picture with a comment system, the picture information is located in one table and the comments is located in another table and each comment is connected to the picture through the id.
I now pull out the picture information with one function like this:
And I now I want to select all the comments to each picture, before when I programmed "none OOP" i just did it like this:PHP Code:function getPicture($cat) {
$sql = "SELECT picture WHERE category = '$cat'";
$result = mysqli_query($this->db,$sql);
return mysqli_fetch_assoc($result);
}
But now I cant place an echo inside the while loop and I can only return one variable (right?).PHP Code:$sql = "SELECT picture WHERE category = '$cat'";
$result = mysqli_query($this->db,$sql);
while($row = mysqli_fetch_assoc($result)) {
$newSQL = "SELECT comments WHERE category = '$row['id']'";
$newRESULT = mysqli_query($this->db,$newSQL);
while($newROW = mysqli_fetch_assoc($newRESULT) {
echo ....
}
}
Is there some way I can select the picture and the pictures comments with the same mysqli_query or something?



Reply With Quote



Bookmarks