I am having trouble getting my include() function to work in my code. Basically I have a the $order array that has the order that my pages will be shown in.
In this case: page numbers: 1,2,3,4,5,6 as seen in the $order array.
If I just post 6 include() function's with the exact path, the pages are shown, however if I try to include them under this for() loop it doesn't work.
$order Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
$fields = 6;
The weird part is if I make the array 4,5,6,1,2,3 it work's perfectly:
$order Array ( [0] => 4 [1] => 5 [2] => 6 [3] => 1 [4] => 2 [5] => 3 )
Only show's first 3 pages
for($x = 0; $x < $fields; $x++)
{
$page_info = mysql_query("SELECT * FROM pages WHERE id='" . $order[$x] ."'");
$pageInfo = mysql_fetch_array($page_info);
$pageNum = $pageInfo['id'];
if($pageNum <= 6)
{
$pagePath = "page" . $pageNum . ".php";
include($pagePath);
}
}
What is confusing is I know it is reading each $pageInfo['id'] because this is the following output:
Output: 123456
for($x = 0; $x < $fields; $x++)
{
$page_info = mysql_query("SELECT * FROM pages WHERE id='" . $order[$x] ."'");
$pageInfo = mysql_fetch_array($page_info);
echo $pageInfo['id'];
}
This works
include("page1.php");
include("page2.php");
include("page3.php");
include("page4.php");
include("page5.php");
include("page6.php");
$pagePath = "page" . trim($pageNum) . ".php";requireinstaed ofinclude, it'll help you to debug.