if in an mysql insert statement
| From: | Mike Teigen | Date: | Mon, 14 Feb 2000 07:53:41 +0000 |
| Subject: | if in an mysql insert statement | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-10238@lists.php.net to get a copy of this message | ||
Is there anyway to have an if statement in the mysql insert function??
I looked in the manual and it said if(test, value1, value2)
Now if test is true value1 will occur if not value2 will occur.. this is all grat makes total
sense... but what if i want more than one if statement in a single entry...
I have this statement:
mysql_query("INSERT INTO subscribers
(first, last, address, city, state, country, zip, phone, email, sourceSite, referer, entryTime,
emailMe, subscribeto) VALUES('$name','$surname', '$address',
'$city', '$state', '$country','$zip', '$phone',
trim('$email'), 'activeassets', '$refer', '$currentDate',
'1', 'if ($circle,1, ), if ($newsclub,33, )')'")
See... what i want for the final insert is for : if $circle is defined then insert ' ,1,'
if newsclub is defined insert ',33,' if they are both defined insert '1,33,'
I dont really know how to do this so if anyone could help that would be great.
Mikey T