homepage Welcome to WebmasterWorld Guest from 107.22.45.61
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
two variables in an if(!$var1$var2)
omoutop




msg:1259038
 10:26 am on Jul 19, 2005 (gmt 0)

Hi to all!

I have this code:

1--<? $Querytype = "select * from Type";
2--$resulttype = mysql_query($Querytype);
3--$timestype = mysql_num_rows($resulttype);
4--$i = 1;
5--while ($rowtype = mysql_fetch_assoc($resulttype)
6--AND $i <= $timestype)
7--{
8--$type1 = $rowtype ['type'];
9--echo $type1;
10--if (!type$i)
11--{?>
12--<input type="checkbox" name="type<? echo $i?>"
13--value="<? echo $type1?>">
14--<? }
15--else
16--{
17--?>
18--<input type="checkbox" name="type<? echo $i?>"
19--value="<? echo $type1?>" checked>
20--<?
21--}
22--$i++;
23--};

In line 10 i have an if statement containing this:
if (!type$i) which is not working....
because itshould be like this:
if (!$type$i) which is also not working...

HOW CAN I HAVE TWO VARIABLES as one string within my if () statement?!
PLZ HELP ME

 

grandpa




msg:1259039
 10:52 am on Jul 19, 2005 (gmt 0)

Try this:

if (!type AND !$i)

webvand




msg:1259040
 11:30 am on Jul 19, 2005 (gmt 0)

Agreed with grandpa,

for a mixing if std. you can use "AND" (or "&&" instead). Also "OR" (or "¦¦" instead) for OR operation.

if ($a == "1" && $b == "1") echo "Both of them = 1";
if ($a == "1" ¦¦ $b == "1") echo "One OR Both of them = 1";

dreamcatcher




msg:1259041
 11:32 am on Jul 19, 2005 (gmt 0)

For more info see:

[uk2.php.net...]

dcrombie




msg:1259042
 1:05 pm on Jul 19, 2005 (gmt 0)

if(!${"type$i"}) { 
// do stuff
}

;)

omoutop




msg:1259043
 1:34 pm on Jul 19, 2005 (gmt 0)

Thx everybody for your replies!

dcrombie u r so right..IT WORKED!
U RULE!
THX MAN!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved