Split Arrays?

Results 1 to 3 of 3

Thread: Split Arrays?

  1. #1
    Join Date
    Dec 1969

    Default Split Arrays?

    I&#039;m trying to store several things in 1 database field<BR><BR>THUMBNAIL:FULLIMG:BACK:ID<BR><BR>the catch is, the data could be<BR> THUMBNAIL:FULLIMG:BACK:ID<BR>or<BR> THUMBNAIL:FULLIMG:BACK:ID,THUMBNAIL:FULLIMG:BACK:I D<BR>or<BR> THUMBNAIL:FULLIMG:BACK:ID,THUMBNAIL:FULLIMG:BACK:I D,THUMBNAIL:FULLIMG:BACK:ID<BR>or it could go on many more times...<BR><BR>How would I dump that into an array (or split, I dunno the difference yet) where each &#039;item&#039; is separated by the comma? Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Split Arrays?

    dataArray=split(dbField, ",") gives you an array. Each element of would contain<BR>THUMBNAIL:FULLIMG:BACK:ID<BR><BR>You can find out how many elements there are in the array by using UBound<BR><BR>numElements=Ubound(dataArray)<BR><BR >You can then split each element into individual data by using split again<BR><BR>for i=0 to Ubound(dataArray)-1<BR> itemArray=split(dataArray(i), ":")<BR> &#060;do some processing&#062;<BR>next<BR>

  3. #3
    Join Date
    Dec 1969

    Default HORRIBLE database design

    DON&#039;T DO IT!<BR><BR>NEVER store a delimited list in a database field if you can help it.<BR><BR>Proper design is to create *another* table (probably two more in your case).<BR><BR>Example:<BR><BR>TABLE: ImageTypes<BR> typeID : Autonumber, primary key<BR> typeName : text<BR><BR>TABLE: TypesToWhatever<BR> whateverID : number, foreign key to Whatever table <BR> typeID : number, foreign key to ImageTypes table<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts