
Pixels & Beats
User
Dec 7, 2009, 4:51 AM
Post #1 of 4
(5690 views)
Shortcut
|
|
Multiple image file names in one database field
|
Can't Post
|
|
Hello CMSB gurus, All data in my database is automatically imported each night from a CSV file. An SQL is then executed on the data to sort it out to match most of the CMSB auto listing database structure. Everything works great (which is testament to the flexible / robust nature of CMSB) except for one issue. Due to the constraints of the import process, the image file names part of the CSV file data, are stored in an odd way in the _uploads part of the database. All image file names are stored in the same field (we will use thumbUrlPath as an example in this case), but they are comma delimited/separated. For example: 000012180_DY02EEG_1908340_MB_391.jpg,000012180_DY02EEG_1908340_IB_082.jpg,000012180_DY02EEG_1908340_IB_334.jpg,000012180_DY02EEG_1908340_IB_646.jpg This obviously causes a problem when trying to display images with the code: echo $upload['thumbUrlPath'] When there is only one image there is no problem and all works fine. In case you are wondering about how it knows the actual path to the file, I have added a field to the database to tell it what the actual path is (in this example we will call it "realUrlPath"), then I join to 2 echo results together to form a whole URL. For example: <img src="<?php echo $upload['realUrlPath'];echo $upload['thumbUrlPath'] ?>" ....... So my problem is how to work with the comma delimited file names. I am hoping that it can be done with some PHP. As all other routes seem to be failing... To pre-empt any suggestions I cannot do the following: 1 - Get the data sent to me using a different structure (I really wish they would just do that) 2 - Automatically manipulate the data when in CSV form 3 - Edit the data by hand (would take far too much time) 4 - Use SQL to separate the data into new fields to use the thumbUrlPath2 fields etc (apparently there is no easy way to do this in SQL, I have tried asking in various places including my Expert Exchange account) I am not a programmer but really a web / graphic / multimedia designer, but because I am the only person here who deals with it, programming is something I am having to deal with more and more. I am learning fast but this one is causing me problems ;) Many thanks Paul aka 8bit Gamer
(This post was edited by 8bit Gamer on Dec 8, 2009, 1:05 AM)
|