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
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.

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.