Im really struggling with adding comments to a user generated php gallery i've made.
I have a database table for the images: userimage (id, imagepath, userid, description) and table image_comment with a foreign key column (comment_id, comment, auther, image_id, comment_date).
My approach has been to make a function with a sql query and call that in my gallery's while loop - hoping to extract the right comments to the matching image in the loop.
FUNCTION:
function getImageComments($imageId){
$query = "SELECT userimage.id, image_id, comment, id, comment_date
FROM userimage, image_comment
WHERE image_comment.image_id=userimage.id
ORDER BY comment_id DESC";
mysql_query($query);}
VARIABLE AND FUNCTION CALL IN THE WHILE LOOP:
while($gallery_data=mysql_fetch_assoc($gallery_result))
{
$gallery_out .= "<div class=\"pic-container\"><img src=\"".$gallery_data['path']."\">";
$imageId = $gallery_data['id'];
$gallery_out .= getImageComments($imageId);
This does absolutely nothing for me, and Im simply stocked here, no fantasy to see how to continue..