How PHP Reads a Page?

I’m trying to echo $page at the top of my pages but it doesn’t work there. It echos the page number on the bottom but not at the top.

Its like it reads the page from top to bottom and then out-puts the page that way i.e. from top to bottom.

I thought it read the whole page completely first then displayed the whole page.

So how do you get a result that ends at the bottom of the page to out-put at the top of the page?

Thanks

Is the page where you are trying to post the result html?

No, its a php page with html on it.

if you post the actual php code, and not the resultant html in the browser, it would help to see exactly what is going on.

I’m not sure what to post as the whole script is on one page. At the bottom right before the footer is this code. “$pages” is here. I can echo the $pages like this:

echo “Total Number of Pages: $pages<br /><br />”;

on the bottom of the page but it doesn’t work if I put it in the top. $pages isn’t mentioned in the script until the bottom when pagination script starts.

if ($current_page != $pages) {
$finals = ($pages - 1) * $limit;
$url = funkify_url("$your_search_page?s=$finals&kw=$append");
			if ($sort_enabled == TRUE && isset($_GET['o'])) {
			$url .= "&amp;o=$o";
			}
echo "<a href=\\"$url\\">$last_text</a>";
}
}
if (!((($s+$limit)/$limit)==$pages)) {
  $news=$s+$limit;
	$next_url = funkify_url("$your_search_page?s=$news&kw=$append");
	if ($sort_enabled == TRUE && isset($_GET['o'])) {
	$next_url .= "&amp;o=$o";

I can post more if code it helps but there’s like 800 lines of code with a lot of commenting.

Thanks

when you say ‘at the top’… I assume you mean at some point AFTER $pages is DEFINED… right?
PHP operates on a linear single-parse, whenever possible. If you put echo $pages; $pages = 1;, you wont get 1 out, because you havent changed $pages at the time you try to echo it.