Welcome Guest, Not a member yet? Register   Sign In
Create a shortable Gallery
#1

[eluser]Lykos22[/eluser]
Hi, I'd like some help please. I've 2 tables:
Code:
Images

img_id (pk)
category_id
image
caption
order

--------------------------
Categories

category_id (pk)
category

I'm just looking for some guidelines in order to create a shortable Gallery like this example (please go to : Portfolio > Portfolio - columns with filter > and choose an option).

I can't figure out though how to develop this. Do I need to have a 'fixed' query, something like:
Code:
SELECT `images`.* , `categories`.`category_name` FROM `images` LEFT JOIN `categories` ON `images`.`category_id` = `categories`.`category_id`
in order to fetch all data or should my query be dynamic, meaning that the `images`.`category_id` will have to change depend on the category selected?

#2

[eluser]InsiteFX[/eluser]
You would need a filter check to see how many columns the user wanted then a for loop to loop through the columns.

Code:
if ($filter_count % 3)
{
    // then display 3 columns on a line then a line break and start the next row.
    // If you wanted 4 columns you would change the 3 to a 4 in the if statement.
}

#3

[eluser]Lykos22[/eluser]
[quote author="InsiteFX" date="1394454807"]You would need a filter check to see how many columns the user wanted then a for loop to loop through the columns.
[/quote]

No, its not the number of columns the point ( it will be always 3). What I 'm talking about is the functionality, when the user click on first category to show only images with this category, so on so on.
#4

[eluser]InsiteFX[/eluser]
Well from the looks of your sql it should work, from looking at their web page it just looks like they are loading a new page with the image gallery images.
#5

[eluser]Lykos22[/eluser]
Yes, but when I click on a category ( for instacne in my example the <package design> category) how can I fetch the images that belong to this category each time? I guess this has to be a WHERE statement but do I also have to do it with Ajax?? in this part I'm confused a bit.
#6

[eluser]InsiteFX[/eluser]
If you are storing the image path in your categories then you should be able to pull the image link out.

You could then just build and echo out a img link.

Javascript would give you a better user experience.




Theme © iAndrew 2016 - Forum software by © MyBB