Need some help with sql/php

Discussion in 'PHP' started by micromark, Oct 29, 2007.

  1. #1
    Hi I am using some code to get a picture out of the database.

    It does this fine. But I want it to display the last 6 pictures uploaded, at the mo it only display 1.

    Here is the code -

    [B<?
    $query="select * from members,photos where members.username=photos.username and active=1 and approved='Y' ORDER BY UPLDATE ASC";
    $result=mysql_query($query);
    
    while($obj=mysql_fetch_object($result))
    
    		if($obj->url=="")
    		{
    			$dpic="<img border=0 src='pics/$obj->filename'>";
    		}
    
    echo "$dpic";
    
    ?>[/B]
    PHP:
     
    micromark, Oct 29, 2007 IP
  2. micromark

    micromark Peon

    Messages:
    466
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ignore those <b> tags
     
    micromark, Oct 29, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  4. micromark

    micromark Peon

    Messages:
    466
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    coz I have changed the code !
     
    micromark, Oct 29, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    You could have used the same topic. At least reply to the other thread with a link to this here, so no one wastes his time with the old code...
     
    nico_swd, Oct 29, 2007 IP
  6. micromark

    micromark Peon

    Messages:
    466
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks.......Back to the question in hand, does any1 have any help ?
     
    micromark, Oct 29, 2007 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    Try this query:
    
    $query="
    	select *
    	from members, photos
    	where
    		members.username = photos.username and
    		active=1 and
    		approved='Y' 
    	GROUP BY photos.url
    	ORDER BY UPLDATE ASC";
    
    PHP:
     
    nico_swd, Oct 29, 2007 IP