Jump to content

array include php (HELP)


paulman888888

Recommended Posts

Am trying to make a games page. Each game is on a diffecent page.

I want to create a master page that includes all the sub pages and am trying to use an array to include them but I only want 10 shown at a time. The reason am useing an array is that i don't want to keep updateing the master page.

 

Thankyou for the help

Link to comment
https://forums.phpfreaks.com/topic/103026-array-include-php-help/
Share on other sites

The code above will work but not show 10 at a time. Instead u can use a for loop:

 

<?php
for($i=0; $i<10; $i++){
   include('games/' . $pages[$i]);
}
?>

 

That will work for the first 10 pages of the array. If u want your pages to be random or anything else, specify it here.

<?php
for($i=0; $i<10; $i++){
   include('games/' . $pages[$i]);
}
?>

it doesn't work, it comes up with

Warning: main(games/): failed to open stream: No such file or directory in /home/www/civage.com/games.php on line 89

Warning: main(games/): failed to open stream: No such file or directory in /home/www/civage.com/games.php on line 89

Warning: main(games/): failed to open stream: No such file or directory in /home/www/civage.com/games.php on line 89

Warning: main(): Failed opening 'games/' for inclusion (include_path='.:/usr/local/lib/php') in /home/www/civage.com/games.php on line 89

 

Please help

 

Thankyou all

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.