I'm trying to create a span page routine in PHP, so that the results can be spread out of several pages. I have the following code;
function generate_toolbar($entries,$page_num) {
$pages = 0;
$pages = $entries / 5;
for ($i =0; $i <= $pages; $i++) {
$page_count++;
}
echo "Entries: $entries Pages: $pages PageNum: $page_num \$page_count = $page_count<BR>";
// go through and actually generate the HTML for the span...
for ($i = 1; $i <= $page_count; $i++) {
echo "\$i = $i <BR>";
echo "$page_num == $i <BR>";
// if its the page number, then dont link, otherwise create a link to that page..
if ($page_num == "$i") {
$_pages .= "<font face=Tahoma size=2 color=black>+$i</font> | ";
} else {
$_pages .= "<a href=\"index.php?action=guest_list&page=$i\">";
$_pages .= "<font face=Tahoma size=2 color=black>_$i</font></a> | ";
}
} // end the 'for'
return $_pages;
}
The above code produces the following output;
$i = 1
1 == 1
$i = 2
1 == 2
Toolbar pages: +1 | +2 |
As you can see, the last 'if' statement seems to match no matter what. Even thought the 4th and 6th lines obviously show that the values should only match on one of the 'if' statements.
Can anyone see why it is doing this? I'm totally stumped
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
// here is where we create the toolbar, with links ... ie. 1 | 2 | 3 | 4 | 5 | 6 function generate_toolbar($entries,$page_num) {
$pages = 0;
$pages = $entries / 5;
for ($i =0; $i <= $pages; $i++) {
$page_count++;
}
echo "Entries: $entries Pages: $pages PageNum: $page_num \$page_count = $page_count<BR>";
// go through and actually generate the HTML for the span...
for ($i = 1; $i <= $page_count; $i++) {
echo "\$i = $i <BR>";
echo "$page_num == $i <BR>";
// if its the page number, then dont link, otherwise create a link to that page..
if ($page_num == "$i") {
$_pages .= "<font face=Tahoma size=2 color=black>+$i</font> | ";
} else {
$_pages .= "<a href=\"index.php?action=guest_list&page=$i\">";
$_pages .= "<font face=Tahoma size=2 color=black>_$i</font></a> | ";
}
} // end the 'for'
return $_pages;
}
The above code produces the following output;
Quote:
Entries: 7 Pages: 1.4 PageNum: 1 $page_count = 2 $i = 1
1 == 1
$i = 2
1 == 2
Toolbar pages: +1 | +2 |
As you can see, the last 'if' statement seems to match no matter what. Even thought the 4th and 6th lines obviously show that the values should only match on one of the 'if' statements.
Can anyone see why it is doing this? I'm totally stumped
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!