Jump to content

Array of images with searching features?


zocheyado

Recommended Posts

So I am working on a project and really am confused on how even to get started, What I am trying to do is create a grid of images and then have a search bar where you can enter in tags that will then highlight each of the images if they have that tag. So say an image had a tree and a tire, the image would have this info either in a Database or something else and then upon searching it would filter the images and then highlight the selected ones as shown below. or leave only the selected ones highlighted. My main concerns are how could I get the images displayed in such a way and then do the highlighting / dimming and what would be the best way to store the tags about the images. I could do a DB and have a column for image src and then tags but I was hoping there would be a way that might be easier? any thoughts on anything? Thanks for any info at all.

kA1QM.png

Link to comment
Share on other sites

You'll have to decide if you want it to work without refreshing the page. If you don't care, then a simple form pointing to the same page would be fine. Every page load you'd just check for the form data and then highlight/dim accordingly.

 

If you don't want the page to refresh, now you'll need some AJAX to call the PHP script. You can then either highlight/dim the images with Javascript or just replace the entire HTML with something returned from PHP. The former would be a little faster, but either works.

 

As for the database, I would probably have at least two tables. One for storing image data, then one for tags. Since each image can have multiple tags, it makes sense to have a one-to-many relationship in the database. That is, one "image" row can have multiple "tag" rows. The "tags" table could just be something simple like: id, image_id, tag_name - with image_id being a FOREIGN KEY reference back to the image's PRIMARY KEY column.

Link to comment
Share on other sites

Actually, the image-tags relation would be many-to-many. Since the same tag can be used on many pictures, and each picture has many tags.

 

I would also recommend building this up to work without AJAX first. After you've gotten that to work, adding AJAX is quite simple and will ensure that your site works regardless of the browser the user is browsing with. ;)

Link to comment
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.