PhotosInAlbums表
使用$mysqli->query()
,我想返回照片表中的photo_id与PhotoInAlbums中的photo_id与相同album_id匹配的所有行。基本上,返回同一专辑中照片的信息(id,title,date_created,date_modified,file_path),这样我就可以在表格中显示这些照片。我该怎么做呢?此外,我对$results2
的查询返回false,我不知道为什么。
代码
//Gets album id from form
$album_id = $_GET['album_id'];
//Returns all photo_id for photos in that album
$result2 = $mysqli->query("SELECT photo_id FROM PhotosInAlbum WHERE album_id = $album_id"); //RETURNS FALSE WHY?
//Returns all the rows where the photo_id matches Photos tables' id
$result = $mysqli->query("SELECT * FROM Photos WHERE id = $result2");
while ( $row = $result->fetch_assoc()) {
print('<div class = "cell">
<div class = "photo_container" >
$title = $row[ 'title'];
$file_path = $row[ 'file_path' ];
print('<img class = "photo_image" src = "'.$file_path.'" alt = "default album" width = "300"/>
print('<div class = "photo_title">'.$title.' ('.$credit.')</div>');
print(' </div>
</div>');
}