Re: [PHP] if and like together?
Tim Thorburn wrote: Is there an IF LIKE statement in PHP? I've got a MySQL database setup with headings and text (think a news article site) - headings in one field, text in another. In some cases, I don't want the contents of the heading field to appear on the site - in these cases, the headings begin with 'noshow-'. So I'm thinking the easiest way to handle this is if there is something similar to the MySQL 'LIKE' command in PHP ... is there such a beast? if(preg_match('/^noshow-/', $heading)){ //Don't show } -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] if and like together?
strstr() and it's variants ereg() if you need more logic Martin -Original Message- From: Tim Thorburn [mailto:[EMAIL PROTECTED] Sent: Monday, 27 October 2003 12:13 PM To: [EMAIL PROTECTED] Subject: [PHP] if and like together? Hi, Is there an IF LIKE statement in PHP? I've got a MySQL database setup with headings and text (think a news article site) - headings in one field, text in another. In some cases, I don't want the contents of the heading field to appear on the site - in these cases, the headings begin with 'noshow-'. So I'm thinking the easiest way to handle this is if there is something similar to the MySQL 'LIKE' command in PHP ... is there such a beast? TIA -Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] if and like together?
Hi, Is there an IF LIKE statement in PHP? I've got a MySQL database setup with headings and text (think a news article site) - headings in one field, text in another. In some cases, I don't want the contents of the heading field to appear on the site - in these cases, the headings begin with 'noshow-'. So I'm thinking the easiest way to handle this is if there is something similar to the MySQL 'LIKE' command in PHP ... is there such a beast? TIA -Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if and...
On Mon, 2003-06-30 at 18:09, Steve Marquez wrote: > I am trying to get php to use two conditions. > > > if ($biz = my_business and $id_num = "1"){ > > echo "stuff" > > } > > if ($biz = "my_business" and $id_num ="2"){ > > echo "other stuff" > > } > > ?> > > My question Is, I am not sure if the "and" is correct, it does not work. Is > there another way to do this? I have tried a plus (+), a (,) and nothing > seems to work. > > Could someone please help? > > Thanks! > > Steve Marquez This is all explained in the manual here: http://www.php.net/manual/en/language.operators.php Essentially, you probably want && instead of and (although and also checks for an 'and' condition, it has lower precedence than &&). Also, you need to use == or === to check for equality. = is the assignment operator, and attempts to assign the value of the expression on the right to the variable on the left. Also, you should quote any strings. So: if ($biz == 'my_business' && $id_num == '2') { . . . } ...etc. Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if and...
if( $biz == "my_business" && $id_num == 1 ) { echo "stuff..."; } if $biz is a string and $id_num is an int... -- BigDog On Mon, 2003-06-30 at 19:09, Steve Marquez wrote: > I am trying to get php to use two conditions. > > > if ($biz = my_business and $id_num = "1"){ > > echo "stuff" > > } > > if ($biz = "my_business" and $id_num ="2"){ > > echo "other stuff" > > } > > ?> > > My question Is, I am not sure if the "and" is correct, it does not work. Is > there another way to do this? I have tried a plus (+), a (,) and nothing > seems to work. > > Could someone please help? > > Thanks! > > Steve Marquez > > Marquez Design > [EMAIL PROTECTED] > > www.marquez-design.com > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] if and...
I am trying to get php to use two conditions. My question Is, I am not sure if the "and" is correct, it does not work. Is there another way to do this? I have tried a plus (+), a (,) and nothing seems to work. Could someone please help? Thanks! Steve Marquez Marquez Design [EMAIL PROTECTED] www.marquez-design.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php