paulman888888 Posted April 26, 2008 Share Posted April 26, 2008 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 Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted April 26, 2008 Share Posted April 26, 2008 what, so, like this? <?php // Your array $pages = array('game1', 'game2', 'game3'); // Loop through the array, and include each one foreach($pages as $page) { include_once("games/$page"); } ?> That sort of thing? Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 26, 2008 Share Posted April 26, 2008 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. Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted April 27, 2008 Author Share Posted April 27, 2008 One more thing. I would like to have a button when clicked picks out a random game. Thank-you for the help Paul Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted April 27, 2008 Author Share Posted April 27, 2008 <?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 Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 27, 2008 Share Posted April 27, 2008 It is supposed that u have a $page array which contains all the pages u want to include: $pages = array('mypage1.php', 'somepage.php', 'etc etc'); And use the right include path, the provided one is an example. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.