SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Aug 2002
    Location
    N.Ireland
    Posts
    1,046
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why is a field repeating?

    I'm working on a website in work at the moment which will give a list of publications held in an Access database. The field "Class"(category) I'm using to generate a menu on the left. Click on a category and it'll bring up all the publications under that category. Now I've two problems with what I've done so far.

    Firstly if you go to this page you will see that the category "Customer Information and External Guidance" has been repeated twice. Why I do not know! I've used the lookup wizard to pull the categories in from another table in the db so the should be no spelling mistakes etc.

    Secondly if you click on a category it only pulls out text before the loop in my script. Click refresh, nothing happens, click the category again and the info I want pulled out is displayed, weird!

    Here's the script


    [VBS] <%
    Dim cn
    Dim rs
    Dim strconn
    Dim strSQL

    set cn = CreateObject("ADODB.Connection")
    strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db/dfppubs.mdb")
    cn.open strconn

    Set rs = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM PUBLICATIONS ORDER by Class"
    rs.open strSQL, strconn

    tempClass = "null"
    Do until rs.eof
    If rs("Class")<>tempClass then
    Response.Write "<tr><td><a href=publicationslist.asp?Category=" & Server.URLEncode(rs("Class")) & " class=submenu>" & rs("Class") & "</a></td></tr>" & vbCrLf
    Response.Write "<tr><td width=180 bgcolor=#999966><img src=../pics/space.gif width=180 height=1 border=0></td></tr>"
    tempClass = rs("Class")
    headerCount = headerCount + 1
    End If
    rs.movenext
    Loop
    rs.close
    cn.close
    %>[/VBS]
    Last edited by Daz; Sep 12, 2002 at 02:52.

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)

    Re: Why is a field repeating?

    Is this the whole code or just the part that seems to be having the problem? I don't see anything wrong with what you are doing so I'm guessing there is more to this code that what you're showing....
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Wizard
    Join Date
    Aug 2002
    Location
    N.Ireland
    Posts
    1,046
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the VB script for the link I posted, all of it.

  4. #4
    \m/ R.I.P. Dimebag! \m/ JimBolla's Avatar
    Join Date
    Dec 2001
    Location
    erie, pa
    Posts
    1,130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that class is in the publications table more than once. try SELECT DISTINCT * FROM PUBLICATIONS ORDER by Class
    -- JIM BOLLA
    Wanna play Halo 2? My XBOX Live gamertag: crowdozer

  5. #5
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Originally posted by crowdozer
    that class is in the publications table more than once. try SELECT DISTINCT * FROM PUBLICATIONS ORDER by Class
    That still shouldn't provide it out of order. The order by clause should at least order it correctly. There is also code there already which handles checking the previous class.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  6. #6
    \m/ R.I.P. Dimebag! \m/ JimBolla's Avatar
    Join Date
    Dec 2001
    Location
    erie, pa
    Posts
    1,130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm. true. the ordering problem has stumped me.
    -- JIM BOLLA
    Wanna play Halo 2? My XBOX Live gamertag: crowdozer

  7. #7
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Originally posted by Daz
    This is the VB script for the link I posted, all of it.
    OK then, can we see the code for publicationslist.asp and see if we can't figure out the rest of the problem? I still don't understand the bit with the order being ignored somehow...

    What platform are you running on? WinNT/2K/Chilisoft?
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  8. #8
    SitePoint Wizard
    Join Date
    Aug 2002
    Location
    N.Ireland
    Posts
    1,046
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dave the site is on a Windows NT server. Here's the VBscript from publicationslist.asp

    [VBS]<%
    Dim cn
    Dim rs
    Dim strconn
    Dim strSQL

    set cn = CreateObject("ADODB.Connection")
    strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db/dfppubs.mdb")
    cn.open strconn

    Set rs = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM PUBLICATIONS"
    rs.open strSQL, strconn

    Do until rs.eof
    If rs("Class")<>tempClass then
    Response.Write "<tr><td><a href=publicationslist.asp?Class=" & Server.URLEncode(rs("Class")) & " class=submenu>" & rs("Class") & "</a></td></tr>" & vbCrLf
    Response.Write "<tr><td width=180 bgcolor=#999966><img src=pics/space.gif width=180 height=1 border=0></td></tr>"
    tempClass = rs("Class")
    headerCount = headerCount + 1
    End If
    rs.movenext
    Loop
    rs.close
    %>[/VBS]

  9. #9
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Huh? OK, now I'm really confused. That looks almost EXACTLY like the code from the publications.asp file you posted in the first post of the topic (minus the order by).

    How are you showing the information for the publications? There isn't any code that I see that will give you the results that your page is doing.

    I'm cornfused.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse


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
  •