Read from DataBase using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

Read from DataBase using PHP

Post by ykarmi »

Hey guys,
I wanted to know what code I should use to read from a database cell that has values separated by a comma?
Say I have the values 1,3,5 and now I want to check if 1 exists withing the string then $one = true for example. How do I verify if the number 1 exists in a certain string (from a database, if that even matters)?
Thanks a lot!
Yuval :D
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I'd be using

Code: Select all

str_split
or

Code: Select all

explode
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

explode() by comma, and in_array() to check if a value exists
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

Thanks!

Post by ykarmi »

Thank you guys, the both of you, you have been great help!
:D :D :D Yuval
Post Reply