Page 1 of 1

Can I do this?

Posted: Mon Jul 03, 2006 9:38 pm
by davidppppppppppp
I have a MYSQL table with 11 entries id's (1 -11).

In my php script I have to use the Eval () on four of those eleven entries.

So I'm using this:

Code: Select all

if ($file == "1") { 

Eval ($content); 

} else { 

echo "$content"; 

}
This just repeats the content - one as it should be displayed and one as the code.

I need some way of doing this:

Code: Select all

$list = (1, 4, 6, ; // the id numbers that need to use Eval() 

if ($file == "$list") { 

Eval($content); 

} elseif ($file != "$list") { 

echo "$content"; 

}

Code: Select all

$list = (1, 4, 6, ;
This gets me errors. How can I define this list of numbers and use the elseif statement?

Thanks,
David

Posted: Mon Jul 03, 2006 9:57 pm
by Luke
use php tags, dude

Posted: Mon Jul 03, 2006 10:16 pm
by davidppppppppppp
OK, I figured it out.

Code: Select all

if ($file == "1" || $file == "4" || $file == "6" || $file == "8") {

                  Eval($content);

          } else {

                  echo "$content";
 
                  }

Posted: Tue Jul 04, 2006 1:24 am
by jmut
davidppppppppppp wrote:OK, I figured it out.

Code: Select all

if ($file == "1" || $file == "4" || $file == "6" || $file == "8") {

                  Eval($content);

          } else {

                  echo "$content";
 
                  }

Code: Select all

$list = array (1, 4, 6, 8 );  // the id numbers that need to use Eval()

if (in_array($file,$list)) {

Eval($content);

} elseif ($file != "$list") {

echo "$content";

}

Posted: Tue Jul 04, 2006 2:59 am
by Jenk
your elseif ($file != "$list") will always amount to true, as you are typecasting $list into a string, when it is an array.

also, it is eval(), not Eval().

:)