1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sending variable to top of page?

Discussion in 'HTML, Graphics & Programming' started by MagSafe, 2 Apr 2007.

  1. MagSafe

    Wise Guy

    Joined: 12 Aug 2004

    Posts: 1,009

    Location: Glasgow, Scotland

    Hi there,

    After searching/looping through a database and bringing back x amount of results, i'd like the x variable to appear at the top of the page after it has finished searching ... is this possible?

    Cheers,

    Steven.
     
  2. Augmented

    Soldato

    Joined: 18 Oct 2002

    Posts: 5,464

    Location: London Town

    Using which language?
     
  3. MagSafe

    Wise Guy

    Joined: 12 Aug 2004

    Posts: 1,009

    Location: Glasgow, Scotland

    ASP / VBScript :)
     
  4. GravyMonster

    Capodecina

    Joined: 18 Oct 2002

    Posts: 14,449

    Location: The land of milk & beans

    all you need to do is run your query at the top of the page, and then loop around the resulting recordset afterward. a bit of psuedocode...

    SQL = "SELECT * FROM Wherever WHERE Whatever LIKE '%Something%'"
    create RS from SQL
    x = RS.Recordcount

    <html>Your search returned X results...

    RS.loop
    display results
    RS.close

    </html>

    Hope this helps
     
  5. roboffer

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 9,599

    Location: Sunderland

    If I remember correctly, its a little awkward to get the recordcount from a results set, you need to specify certina options in the record set when you open it
     
  6. MagSafe

    Wise Guy

    Joined: 12 Aug 2004

    Posts: 1,009

    Location: Glasgow, Scotland

    yeah, but i'm doing a few if statements within a couple of loops as well, and i need the variable that appears at the bottom of the page to somehow appear at the top :confused:

    cheers for the comments so far :)
     
  7. Conrad11

    Soldato

    Joined: 12 Jun 2005

    Posts: 5,362

    I may be missing the point, but surely you would just construct the html first and then output it.

    EDIT:

    Do sql statement that counts the number of returned records?
     
    Last edited: 2 Apr 2007