Jump to content

Theoretical Help


Ortix

Recommended Posts

Ok so this is more of a theoretical question than one where I ask for a piece of code. I can't seem to figure out a way to run a certain script so I am here to ask for your help. It is somewhat of a long read but please read it all and don't skim if you're planning on helping.

 

Here's the gist. I am writing a script which inserts filenames and URLS into a DB. This creates an Item and each item should have an image. Every item has 2 filenames and 2 URLS (same file, different URL for mirroring purposes). So in the frontend you would see 2 filenames exactly the same but with 2 different URLS. Since it's a batch insertion script I decided to do it like this:

 

2 text boxes where the user drops all the filenames and next to it their RESPECTIVE URLS. These filenames don't have a specific order but the URLs and filenames do match in order.

 

The problem is the images. I was planning on using a 3rd text box where the user would drop the image URLs but there are let's say 5 images but 10 filenames and URLs. So there is no way of matching the image to the correct file. The script however does iterate over each filename, checking if it exists in the DB. If it does, it will simply add the second url to the item so the image 'insertion' part will ONLY run once the item is newly created and NOT when updated with a second URL. It's basically a foreach loop and I iterate over an array of filenames and URLs.

 

So basically the problem is that I have no idea how to match the images to the correct filenames since order won't work anymore due to there being half as many images as filenames.

 

Anyone with a brilliant idea?

Link to comment
Share on other sites

Ok I think i figured it out. I am going to sort the file array (keeping the key intact) which will return it in the right order, then the image urls can be pasted in that order and i'll just insert an image only if the item is new :D booya!

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.