Hi, When I am using echo to display the result it gives only 1 'result', what i want is say 5 results. How could I do this ? Ta.
<? $numcomments=0; $nomember=false; $case=0; if(empty($username)) { $sql="select * from members,photos where members.username=photos.username and active=1 and approved='Y' ORDER BY DESC LIMIT 1"; } else { $sql="select * from members where username='$username' and active=1"; $case=1; } $res=mysql_query($sql); { $username=$obj->username; } else { $nomember=true; $msg="No Pictures Exist!"; if($case==1)$msg="No member exists with that username"; } if(!$nomember) { $sql="select * from photos where username='$username' and approved='Y' order by upldate desc"; $res=mysql_query($sql); $num=0; if(mysql_num_rows($res)!=0) { $rnum=rand(0,mysql_num_rows($res)-1); } else { $nomember=true; $msg="No Pictures Exist for that username!"; } while($obj=mysql_fetch_object($res)) { if($obj->url=="") { $dpic="<img border=0 width=100 height100 src='pics/$obj->filename'>"; } else { $dpic="<img src='$obj->url'>"; } if((empty($phid)&&($num==$rnum))||($phid==$obj->photosid)) { $photoid=$obj->photosid; $pic=$dpic; $allpics=$allpics."<b>".($num+1)."</b> "; } else { $allpics=$allpics."<a href='index.php?username=$username&phid=$obj->photosid'>".($num+1)."</a> "; } $num++; } } echo $dpic; ?> PHP:
I have change it 5 thats how many I want. And I just get 1 picture back. I want the last 5 uploaded arranged in a table
What should I do I need the last 5 pics that have been uploaded display at the mo the echo $pic just gives me 1 pic
As bobb1589 said, you need to put the $dpic inside the while loop. To do so, put $dpic BEFORE $num++; echo $dpic; $num++;