Jump to content

Recommended Posts

I have a comma separated list of thumbnails coming from my database for each album. I need to add the path to the beginning of each element like so

 

$event['thumbnails'] = thumb.jpg, thumb2.jpg, thumb3.jpg, thumb4.jpg

 

I need to make it so the list above looks like http://site.com/medi...humbs/thumb.jpg, http://site.com/medi...umbs/thumb2.jpg, http://site.com/medi...umbs/thumb3.jpg, http://site.com/medi...umbs/thumb4.jpg

 

How would I go about doing that and ensure that it stays as a comma separated list instead of turning it into an array? Thanks!

Edited by RyanMinor

This is my database query

 

SELECT event.*, GROUP_CONCAT(photo_thumbnail) as thumbnails
FROM event
LEFT JOIN photo ON event_id = photo_event
WHERE event_user = ?
GROUP BY event.event_id;

 

So I am left with an array in which one of the keys is a comma separated list of thumbnails. I am doing it like this because I am using the live jQuery thumbnail script.

Why not do all the hard work in the query?

 

SELECT event.*, GROUP_CONCAT(CONCAT(?, photo_thumbnail) SEPARATOR '|') AS thumbnails …

 

Then pass in the URL prefix as a query parameter, like you do with event_user.

 

This would return the thumbnail URLs in the correct format that you can just plonk into the data-images attribute in your HTML.

Edited by salathe
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.