| Posted by Krustov on 12/03/07 00:04 
A loop might a be idea if everything is a number .
 $loopy=1;
 while ($loopy<20)
 {
 if ($imagecat==$loopy) {$batman=$loopy . ".php"; include($batman);}
 $loopy=$loopy+1;
 }
 
 The above code is untested and really just intended to get you started .
 
 
 <comp.lang.php>
 <>
 <Sun, 2 Dec 2007 15:44:12 -0800 (PST)>
 <bd28edd9-c1b5-4470-b158-1f54eb599c3e@e4g2000hsg.googlegroups.com>
 
 > I am trying to generate an include name on an image gallery page from
 > a variable name.
 > By this I mean I already have a numeric value set the variable
 > $imageCat.
 >
 > What I want to do is pull in an external include file using the
 > variable as the file name. So if $imageCat is set to 2 I want to bring
 > in 2.html ($imageCat.html).
 >
 > I can hard code each include request as such:
 >
 > {if $imageCat=="2"}
 > {php}
 > include ("2.php");
 > {/php}
 > {/if}
 >
 > But I am dealing with oodles of categories so this file would be huge.
 > A dynamic option would be very cool but I just can't seem to get my
 > syntax right.
 >
 [Back to original message] |