OK,
This is what I have tried:
$page_bar = array
(
'page' => $page_nav_bar,
'stat' => $page_stat_bar
);
return "$page_bar";
}
this returns ( array ) when I run my function now if I put return "$page_bar[page]"; it will return the correct stuff for the var $page_nav_bar and I am not able to have the $page_stat_bar show when its needed
below is the full code for the function:
<?php
// $searchquery = "test"; // var from url
// $totalrecords = 172; // total rows found from the search
// $pagenumber = $_GET['pn']; // page number that is being displayed
function page_bar($display, $searchquery, $totalrecords, $offset, $pagenumber = '1', $recordsperpage = '20')
{
$firstpage = 1; // first page
$lastpage = ceil($totalrecords/$recordsperpage); // last page
$page_nav_bar = ''; // var thats used to hold what will be displayed for the page nav bar
if($pagenumber > $firstpage)
{
$page_nav_bar .= "<a href=\"http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] ."?sq=$searchquery&pn=$firstpage\">First</a> ";
$page_nav_bar .= ' | ';
$prevpage = $pagenumber - 1;
$page_nav_bar .= "<a href=\"http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] ."?sq=$searchquery&pn=$prevpage\">Prev</a> ";
}
$page_nav_bar .= " Page $pagenumber of $lastpage ";
if($pagenumber < $lastpage)
{
$nextpage = $pagenumber + 1;
$page_nav_bar .= "<a href=\"http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] ."?sq=$searchquery&pn=$nextpage\">Next</a>";
$page_nav_bar .= ' | ';
$page_nav_bar .= "<a href=\"http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] ."?sq=$searchquery&pn=$lastpage\">Last</a>";
}
$page_nav_bar .="
<form name=\"goto_page\" action=\"". $_SERVER['PHP_SELF']."\" method=\"GET\">
<input type=\"hidden\" name=\"sq\" value=\"$searchquery\" />
Goto page: <input type=\"text\" name=\"pn\" size=\"1\" maxlength=\"2\" />
<input type=\"submit\" name=\"go\" value=\"Go\" />
</form>";
if($display == 1)
{
$dsn = $offset + 1;
$den = $offset + $recordsperpage;
$process_time = '0.01 Sec';
$page_stat_bar = "Your search for $searchquery found $totalrecords displaying $dsn to $den ($process_time)<br /><br />";
}
else
{
$page_stat_bar = "";
}
// $page_bar = $page_nav_bar;
// $page_bar .= $page_stat_bar;
$page_bar = array
(
'page' => $page_nav_bar,
'stat' => $page_stat_bar
);
return "$page_bar";
}
// echo "<center>" . page_bar($searchquery, $totalrecords, $pagenumber) . "</center>";
?>
if you look I have // out two var if I unblock them and block the array then it will work the way I want but I then don't have contral over where the sec part goes and thats not good either 🙁
Any advice would be greatly thankful!
Sincerely,
Christopher