Better way of doing things PHP/mySQL

This is just a question on what is a better way of doing things…

Currently I am using a for loop in PHP to name everything…
name$i etc.
Then in flash I am using another for loop to put everything where I want it…

On the other hand, I could be sending everything to Flash in one piece, then cutting it into an array in Flash. And then running a for loop to put everything where I want…

If I am right, the way I am doing it is sending more information to Flash because everything has its own var name with it.

But then I am saving Flash work because it doesn’t have to split() it into an array.

Is there any pro’s or con’s as to which way is better ?

Howdy… :slight_smile:

I think it mostly depends on how many items you are sending out from the PHP and how tidy the code should be…

For example, if I am sending out 10 variables, a0, a1, a2, … , a9, then it might be better to send them out in one long line with the delimeter like this…

&variableA=valueForA0~valueForA1~valueForA2~valueForA3~valueForA4~valueForA5~valueForA6~valueForA7~valueForA8~valueForA9&

rather than sending them out individually like this…

&a0=valueForA0&a1=valueForA1&a2=valueForA2&a3=valueForA3&a4=valueForA4&a5=valueForA5&a6=valueForA6&a7=valueForA7&a8=valueForA8&a9=valueForA9&

That way you can just call up the split(“~”) function in Flash to generate the array…

But, that will only work if you have simple data structure… The code will be confusing to deal with especially when you do the maintenence later on if you use that with many data records from the backend…
Of course, it would be a good idea to look for the Remoting if you are sending out big chunk of data back to Flash since Flash sucks at dealing with big data split and whatever else that goes with big data… :frowning:

Just my 2 cents, of course… :slight_smile:

sending out big chunk of data back to Flash

Well what constitutes a big chunk of data ?

At the moment I am sending it to a drop down box in the form of:
name1 = bob
name2 = sam
name3 = mark

The largest I wil have to deal is ??? 100-200 ???

I don’t think that won’t really hurt much, but I’d go with one long line divided by the delimeter because that can save you at least 5 bytes * 200 items when sending out the data back to Flash…

What I meant by ‘bid data’ is whatever you see that affects the performance of your Flash movie… Have your Flash movie load 200 data set from the PHP and have it parsed into the array… See how long it takes… If you think it is durable when tested on the host, then it probably is fine… But if it takes, like, 10 seconds, it might not be a good sign… Something like that… You get the drift… :slight_smile: