Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help ceating a loop

    Hi,

    Im looking for a shove in the right direction here,
    I have a query in sql server which returns:

    ID sname fname text
    5426 cosgrove, Valerie Peggy
    5426 Cosgrove, Valerie smith
    5426 Cosgrove, Valerie 21/10/2009
    5420 McGonigle, Elaine Lynsey
    5420 McGonigle, Elaine Crean

    What I need is one record for each existing ID, but with 2 extra text fields at the end to hold the other bits of data for that ID, eg

    ID sname fname text text2 text3
    5426 cosgrove, Valerie Peggy smith 21/10/2009

    Im just not sure how to loop through the returned records, any ideas appreciated!

    Regards
    DW

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    You don't mention what language you're using. Also, show the current query.
    Are you a Help Vampire?

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    Its SQL embedded in html, the original qry is

    SELECT e.id, e.name, e.email, e.survey_id, a.question_id, a.text
    FROM tbl_Entrant e INNER JOIN
    tbl_Answer a ON e.id = a.entrant_id
    WHERE (e.survey_id = 6) AND (e.name IS NOT NULL) AND (e.name <> '') AND (e.status IS NULL OR
    e.status = 1) AND (a.question_id = 98 OR
    a.question_id = 99 OR
    a.question_id = 104)
    ORDER BY e.id DESC

    Thanks

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    HTML doesn't doesn't query a database. It's just client-side presentation. So "SQL embedded in HTML" doesn't really make sense. There must be a language that handles the querying and results. You need to provide that code.

    The query above should return all six fields in a row in the result set, so the language must be formatting the results to display the way you showed in the original post. Without code or even knowing which language you're using, it's impossible to help.
    Are you a Help Vampire?


  •  

    Tags for this Thread

    Posting Permissions

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