Select values to array???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LauraL
    New Member
    • Apr 2007
    • 1

    #1

    Select values to array???

    Hi guys,

    I have a problem which I'm not able to solve in any way. I'm trying to add a 'random album thumb' feature to my php photogalley.

    I have two tables in mysql database: photo_albums and photos. My idea is first to:

    1) select all the different album numbers from 'album_number' column of photo_albums table that are the sub albums for example album '5'. So I would get an array containing for example several album numbers like (3, 45, 67, 34 etc).
    SELECT album_number FROM photo_albums WHERE album_sub=5)

    2) Then I would go to 'photos' table in my database and select random photo where photo belong to one of the album numbers in array (3, 45, 67, 34 etc).
    When some album has no pictuers in it, it should loop until it reaches the album number which has photos.

    How could I do this? I'm quite new to php, so I desperately need your help.

    Thanks in advance,
    Laura
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    This looks like it could be done in one SQL query rather than using PHP loops, and multiple queries. Post the relevant table structures and explain in database terms what you want to do

    Comment

    Working...