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

explode

P: 29
hello friends.... in my database table i have a filed called "terms" in which i have stored values as 1,2,3,4. i want to retrive this value and display the names coreesponding to each value.

Ie. if 1 represents- ab and 2 represents- bc and 3 represents -cc i want to display it as
ab
bc
cc

i am told it can be done using explode. i am new to php , so can anyone please tell how to do this work

Thanks
Oct 16 '08 #1
Share this Question
Share on Google+
5 Replies


Dormilich
Expert Mod 5K+
P: 8,639
If you could show me the database table structure (the description doesn't clarify that) I can probably tell you how to arrange that. right now I'm not sure if explode() is the right means there. (explode() converts a string into an array)

regards
Oct 16 '08 #2

chelvan
P: 90
hi
i also thought like, Dormilich.

but you can do this by select query. why u don't like go with that.

regards
chel-1
Oct 16 '08 #3

P: 29
hi.... how can i do that with select query. select query goes like this...
select terms,state,zipcode from tablename. here the terms field contains values stored as 1,2,3... i have a value for 1,another value or 2 etc..i want to get values corresponding to these numbers. but in the db field it is stored as 1,2,3. then how can do it with select query.....


Thanks
Oct 16 '08 #4

ak1dnar
Expert 100+
P: 1,584
ajay,
Please be more specific.I have no idea what is being asked.
If you can explain your problem in detail, our experts will help you on this. Thanks
Oct 16 '08 #5

dlite922
Expert 100+
P: 1,584
hi.... how can i do that with select query. select query goes like this...
select terms,state,zipcode from tablename. here the terms field contains values stored as 1,2,3... i have a value for 1,another value or 2 etc..i want to get values corresponding to these numbers. but in the db field it is stored as 1,2,3. then how can do it with select query.....


Thanks
Since we can't seem to understand what you're asking, how about we explain what explode does and see if that will help you.

$myArray = Explode("1,2,3,4",",")

produces

an Array("1","2","3","4");

The comma separated values are now in individual indexes of the array and can be accessed like so:

echo $myArray[0]

The above would print 1.

Is this what you want?



Dan
Oct 16 '08 #6

Post your reply

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