By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

problem insert values into table using tokenizer..

P: 2
hi frds...
in my hiden textbox.i have following values...
robert|true|true|false|arun|true|false|true|anu|tr ue|true|false|

i want to splits in to token and insert in mysql table in following manner

namefield writefiled readfield speakfield
robert true true false
arun true false true
anu true true false

thanks in advance...
Sep 16 '09 #1
Share this Question
Share on Google+
1 Reply


dlite922
Expert 100+
P: 1,584
best way is to split the string with its delimiter (in your case the bar) then loop through each value. If the value is not true or false, store it in an array as the key (save this value) the next iterations (the true and false values) will be stored under this key so you'll have:

$array[robert] = array(true, true, false);
$array[arun] = array(true, false, true);

so on and so forth

next loop this array taking the key and values (hint: use a foreach with key and value extracted and use implode to glue the true/false values back together with a comma or whatever format you need it in.

PMed you the code I posted and got deleted by Atli.

I knew he's trying to prevent copy/paste solutions in the forum, but this was so simple that it was better to code it than explain it.

Besides, if you're at this point, you had had to know the basics of programming (arrays, loops, variables) to continue finishing the rest of the program.

Good luck,



Dan
Sep 17 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.