Jump to content

Recommended Posts

Hi guys n gals - a tuff query I am struggling with...

 

I have a table of media (video and audio) these play in a flash player.  The videos are fine but the audio have images associated with them...

 

What i need is to select media from this database and when the record is an audio file select an image to go with it.

 

the record has a field `imgs` which contains a , delimted string of numbers - these represent the id of an image in another table.

I just want to select a random image from that string of ids or just the 1st id in the string and i'd LOVE to do it in one query!

 

[pre]

media table

med_id ... type      imgs

1            audio    1,2,4,5

2            video

3            video

4            audio    7,8,9

 

images table

img_id    path

1          /pics/abc.gif

2          /pics/def.jpg

3          /pics/ghi.gif

.......

[/pre]

 

Hope I have explained enough for you to understand - if not tell me off and I'll try again...

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/73453-tough-query/
Share on other sites

I guess it depends on how you have every thing set up. If you have a set amount of images (img1 - img7) and the audio records relate and reuse the images. Like audio1 uses img1, img3, and img4 and audio2 uses img2, img5, and img1 then I would create another table that holds that relation between the two tables.

Link to comment
https://forums.phpfreaks.com/topic/73453-tough-query/#findComment-370831
Share on other sites

I guess it depends on how you have every thing set up. If you have a set amount of images (img1 - img7) and the audio records relate and reuse the images. Like audio1 uses img1, img3, and img4 and audio2 uses img2, img5, and img1 then I would create another table that holds that relation between the two tables.

Doesn't matter how it's set up -- always use a many-to-many table for stuff like this.

Link to comment
https://forums.phpfreaks.com/topic/73453-tough-query/#findComment-370836
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.