If operators
Posted: Mon Feb 18, 2008 4:34 pm
I need an if statement that would be true if a field only contained the variable and not equaled it.
I have a table with sales reps and their preferred method of contact. If it is emailed it always has an E in the string, faxed is F and mailed is P (for print it). The problem is that (for various reasons) there could be several combinations to the string:
1PI Account that was generated through internet sales that wants mail
1PH House account that prefers mail
2FI Internet account that wants faxes
2FH House account that wants faxes
There are dozens of these but always with E, P, F. Different sales reps get different numbers in front and the last number is the place the sale was generated.
Now the if statement would be something like:
Except "=" will not work. Is there a "contains" operator. I have been searching but I haven't found anything yet. I know there is an "or" operator but that seems like a poor solution as these strings could change with new additions.
A little addition here:
I am always looking at the second letter of the string so that may be a way to do this. Format it so that the first and last letter are striped and then compare whats left?
I have a table with sales reps and their preferred method of contact. If it is emailed it always has an E in the string, faxed is F and mailed is P (for print it). The problem is that (for various reasons) there could be several combinations to the string:
1PI Account that was generated through internet sales that wants mail
1PH House account that prefers mail
2FI Internet account that wants faxes
2FH House account that wants faxes
There are dozens of these but always with E, P, F. Different sales reps get different numbers in front and the last number is the place the sale was generated.
Now the if statement would be something like:
Code: Select all
if ($rowcust['REP_ID'] = "E"){
$email=$rowcust['E_MAIL'];}
elseif ($rowcust['REP_ID'] = "F"){
$email=$rowcust['FAX'];}
else {$email=$rowcust['PRINT'];}
A little addition here:
I am always looking at the second letter of the string so that may be a way to do this. Format it so that the first and last letter are striped and then compare whats left?