Return A Value To The Top Of The Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajm113
    New Member
    • Jun 2007
    • 161

    Return A Value To The Top Of The Script

    Ok, I have a page that writes the results that are shown and I would like to count them then return the number wich would be stored in a variable to the top of the page. So it can show how many results it retrived. Then showing at the bottom which would not help the user that much if their was a thousand results.

    Example of a code that does not work.

    [PHP]$NumOfResults = 0;

    echo "There Are ".$NumOfResults ." result(s)."; //Display number of rows.

    while(mysqlResu lts)
    {
    $result = $row[result];

    $NumOfResults++ ;

    echo $result;
    }[/PHP]
    This is just a example just to give you a idea what I am trying to do.

    I know I can use the mysql function to retrive the results, but It does not help for the results that are really displaying.
  • vituko
    New Member
    • Dec 2006
    • 48

    #2
    instead of
    [PHP] echo $result;[/PHP]
    do [PHP]$string .= $result ;[/PHP]
    and then
    [PHP] echo "There Are ".$NumOfResults ." result(s).";
    echo $string ;[/PHP]

    You can also control the output buffer (obstart / obgetclean / ...)
    Last edited by ak1dnar; Dec 22 '07, 06:27 AM. Reason: Fixed CODE tags

    Comment

    • Ajm113
      New Member
      • Jun 2007
      • 161

      #3
      Thank you very much for your reply. This will indeed help me with my project a lot. :)

      Comment

      Working...