Jump to content

INCLUDE in a loop?


Dekieon

Recommended Posts

I am trying to do an include in a while loop and it doesn't work.

If have the while loop print out the filename, it loops twice for me, which is how many times it should loop.

When I try to include a file it only seems to loop once.

 

$query  = "SELECT * FROM `blocklayout` WHERE `column`='right' ORDER BY `weight`";
$result = mysql_query($query);

while($row = mysql_fetch_array($result))
{
   echo " ".$row['filename']; 
   include "./blocks/".$row['filename'];
}

 

 

What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/43852-include-in-a-loop/
Share on other sites

$query  = "SELECT * FROM `blocklayout` WHERE `column`='right' ORDER BY `weight`";
$result = mysql_query($query) or DIE(mysql_error());

while($row = mysql_fetch_array($result))
{
   echo " ".$row['filename']; 
   include "./blocks/".$row['filename'];
}

 

Try that and see if an error is thrown.

Link to comment
https://forums.phpfreaks.com/topic/43852-include-in-a-loop/#findComment-213207
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.