Ortix Posted November 8, 2011 Share Posted November 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/250683-theoretical-help/ Share on other sites More sharing options...
Ortix Posted November 8, 2011 Author Share Posted November 8, 2011 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 booya! Quote Link to comment https://forums.phpfreaks.com/topic/250683-theoretical-help/#findComment-1286157 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.