PDA

View Full Version : variables in a while loop


Jakeman
06-15-2002, 08:23 AM
my objective: to duplicate a forum in my forumbits so it is displayed twice on my forumhome, at two different spots.

problem i'm having: the variables i am putting the forum values into are not being passed into the next loop when the while loop repeats itself. the result is a duplicate forum without any values for variables in the forumbit template (basically a blank row in my forumhome forum listing).

fyi: i have copied the function i am modifying from the forum/index.php file for vB 2.2.6 (see attached file). my code additions are marked with comments. there are two sections of my code. the top section assigns variable values during a certain loop, the bottom section uses those values in a later loop.

question: how do i pass on the variable values so they can be used in a later instance of the while loop? or am i wrong about the problem and is this not the right question? ;)

thx for any help :)

Admin
06-15-2002, 04:45 PM
Not sure what you're trying to do, but add $gameforum to the list of global variables in makeforumbit().

Logician
06-15-2002, 06:55 PM
Your problem might be related to this line:

if ($forum[forumid]==19) {

I assume you have 18 forums and you want to assign the saved one as 19th. If this is the fact you are missing the point that since you have 18 forums this conditional will be never be TRUE so will not be parsed.

If this is the problem set it to 18. The better is put a
$i++;
echo $i;

debug line inside while and see what will be $i get at the end of while.

Or put line
echo "came here";

after
if ($forum[forumid]==19) {

and see if conditional is parsed.

Jakeman
06-15-2002, 07:22 PM
that worked firefly. see the end result here: http://www.macsubculture.com/forum/

notice my MSC clan forum and Games forum. the Games forum isn't really a forum, just a duplicate of the MSC clan forum with a different name that links to the MSC clan forum and mirrors all its forumhome stats.