SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Is the page where you are trying to post the result html?

  3. #3
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, its a php page with html on it.

  4. #4
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


    Code PHP:
    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

  6. #6
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •