Jump to content

Recommended Posts

Hi all

I have a field in my database which contains letters such as

d,h,u,z

I want to write a if statement to print the word "done" if the statement equals any of the letters in the field, I currently have

[code]if ($arow['letters'] == 'a,b,f') { print "done"; }[/code]

But that has to match what is in the database, where I want to be able to have just one letter in the if statement and if will print if the letter appears anywhere in the field.

Does that make sense?

Thanks in advance for any help

Thanks

Ed
Link to comment
https://forums.phpfreaks.com/topic/13595-php-if-statement-question/
Share on other sites

Sorry I think you misunderstood me, basically at the moment I have loads of rows in my database and in the database field called "letters" there is letters seperated by a commas, for example one row has

d,f,g

What I want to do is run a if statement like the following

[code]if ($arow['letters'] == 'a') { print "done"; }[/code]

At the moment it will never print the word "done", simply because there is no row with a single value in it such as 'a' or 'g', there is only multiple values such as

e,g,j
b,d,f
a,d,m

What I want to do is to get the if statement to look for any rows which have the given value in them, ignoring the fact that there is other values in it, the if statement would just look for rows where the value appeared, not match the field value exacly.

Does that make more sense?

Thanks

Ed
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.