PHP/Mysql array_pop missing first value -
basically happens this:
a person goes specific gallery, galleryid=42. query grab of images in gallery (with value of galleryid=42), , separate query grab of comments associated gallery (for example galleryid=42). there may 4 comments total on 3 different pictures out of 400 total images.
as loop through images do/while loop, , display them, search array of comments have been placed each picture loops. if finds picture id matches specific picture, displays comment values (comment, commentauthor, , commentdate).
here query images:
select * gallerydata galleryid = 42
and query comments:
select comment, commentauthor, commentdate, id comments categoryid=42
then use code put comments in reusable query:
while(($comments[] = mysql_fetch_assoc($rscomments)) || array_pop($comments));
then use this loop through array find comments associated particular picture
foreach($comments $comment) { if($comment['id'] == $row_rsgalleries['id']) { echo '<p>'.$comment['comment'].' - '.$comment['commentauthor'].'</p>'; } }
problem is, code seems not include first comment in query.
now, 1 of first projects have done this, , not php/mysql expert, novice user.
when run query, comes 4 results, array includes 3, first result missing.
this construct looks totally crazy me. don't understand why cut off first element, don't feel inclined spend time find out: need fix statement. using ||
in context never going give result want.
can describe supposed do?
Comments
Post a Comment