Avatar billede txk Nybegynder
22. marts 2002 - 19:26 Der er 16 kommentarer og
1 løsning

Tabel menu

Jeg har en menu som henter data fra en .mdb
den ser sådan ud:

1    2    3
1,1  2,1  3,1
1,2  2,2  3,2
1,3  2,3  3,3

Men jeg vil have det hele i en kolonne

1
1,1
1,2
1,3
2
2,1
2,2
2,3

koden ser sådan ud:

<%
Response.Buffer = false

sql = "select * from tbloverskrift where aktiv = true"
rs.open sql, conn
dim varTemp()
dim intCount
Response.Write "<center><table border=0 cellspacing=0>"
Response.Write "<tr>"
do while not rs.eof

Response.Write "<th bgcolor='#c0c0c0'>" & rs("overskrift") & "</th><th bgcolor='#c0c0c0'> </th>"
intcount = intcount +1
    redim preserve vartemp(intcount)
    vartemp(intcount) = rs("id")
rs.movenext

loop
rs.close

dim i
Response.Write "</tr><tr>"

for i = 1 to intcount
sql = "select * from tblmpunkt where fk_overskrift = " & vartemp(i)
rs.open sql, conn

Response.Write "<td valign='top'>"
do while not rs.eof

Response.Write "<li><a href='" & rs("url") & "'>" & rs("mpunkt") & "</a></li>"

rs.movenext
loop
Response.Write "</td><td> </td>"
rs.close
next
Response.Write "</tr></table></center>"


%>


hvordan skal koden se ud for at det bliver i 1 kolonne ?
Avatar billede terry Ekspert
22. marts 2002 - 19:39 #1
do you have three fields in each record? does the first record contain 1 2 3?

Why dont you alter the layout of your table?
http://exp.dk/spm/188486
Avatar billede txk Nybegynder
23. marts 2002 - 00:56 #2
Would you create an example of that and send the database to me? I don't really get it.  ??
Avatar billede terry Ekspert
23. marts 2002 - 09:28 #3
I can send you the dB (table) I sent pelkjaer in the other question.
do you have an email?
Avatar billede txk Nybegynder
23. marts 2002 - 15:39 #4
http://www.asp.dk/sources.asp?mode=view_source&tech_id=1&id=1501

go there and you can find a live demo and you can download the sourcekode with the database.

that is the one i am trying to change
Avatar billede terry Ekspert
23. marts 2002 - 15:57 #5
hi txk>I am not too hot on ASP but have had a look at the demo and the database.
As far as I can see it is only possible to have "hovedpunkter" and "underpunkter", you can NOT have "underpunkter" to "underpunkter. The example I gave in http://exp.dk/spm/188486 can be done with one single table but it requires coding a recursive function. A recursive function is one whích calls itsself while it traverses down the menu structure.
Avatar billede txk Nybegynder
23. marts 2002 - 16:09 #6
i do not want to have 2 "underpunkter".

did you download the code ?

I know that it is possible to change the code
so that i get:

"hovedpunkter"
  "underpunkter"
  "underpunkter"
"hovedpunkter"
  "underpunkter"
Avatar billede terry Ekspert
23. marts 2002 - 17:30 #7
txk> I know how to read your the data from the database in the correct order but as I said, I am not HOT on ASP (HTML) so I cant say how your code is will be. I CAN SAY though that you will need two recordsets, one for the main menu's "hovedpunkter" and one for the sub  menues "underpunkter". If you can alter the HTML the I can explain how to  read the dB.

I have modified the code so as to read the database in the correct order (NOTE: There are two recordsets so the new one needs DIM'ing)

The HTML will more than likely be wrong, so you can see igf you can get that coorect!

mvh
Terry
Avatar billede terry Ekspert
23. marts 2002 - 17:31 #8
<%
Response.Buffer = false

sql = "select * from tbloverskrift where aktiv = true"
rs.open sql, conn
dim varTemp()
dim intCount

do while not rs.eof

    Response.Write "<th bgcolor='#c0c0c0'>" & rs("overskrift") & "</th><th bgcolor='#c0c0c0'> </th>"

    sql = "select * from tblmpunkt where fk_overskrift = " & rs("id")
    rs2.open sql, conn


    do while not rs2.eof

        Response.Write "<a href='" & rs2("url") & "'>" & rs2("mpunkt") & "</a>"

        rs2.movenext
    loop
    rs2.close

    rs.movenext

loop
rs.close

%>
Avatar billede terry Ekspert
23. marts 2002 - 17:32 #9
dim varTemp() and dim intCount are NO LONGER needed!
Avatar billede nih Novice
23. marts 2002 - 17:36 #10
Jeg er ikke god til ASP, men hvis ikke andre vil, så kommer jeg med et forslag.

Du skal have 2 recordset:
sqlHvdPkt = "select * from tbloverskrift where aktiv = true"
rsHvdPkt.open sql, conn
og
sqlUndPkt = "select * from tblmpunkt"
rsUndPkt.open sql, conn

Så skal du køre nogle loops:

do while not rsHvdPkt.eof
  ASP.Skriv.enlinje = rshvdpkt("overskrift")
  rsUndPkt.movefirst
  do while not rsUndPkt.eof
    if rsUndPkt("fk_overskrift") = rshvdPkt("ID") then
      ASP.Skriv.enlinje = rsUndpkt("URL")
    end if
    rsUndPkt.movenext
    loop
  rshvdPkt.movenext
loop

Du skal altså lave et indlejret loop.

Niels
Avatar billede nih Novice
23. marts 2002 - 17:39 #11
Hi Terry - maybe we schould learn this ASPthing

Niels
Avatar billede terry Ekspert
23. marts 2002 - 18:09 #12
Hi niels>Well actuallyy I have done a bit with it but it isnt in the finger tips like  Access and VB so I have to test everyting to make sure that its correct and it takes far too long!

mvh
Terry
Avatar billede txk Nybegynder
23. marts 2002 - 18:31 #13
I have testet both codes but non of them worked...
terry you did not test you code on you comp did you?
Avatar billede terry Ekspert
23. marts 2002 - 19:00 #14
No! I have only altered the code to read the database, you need to ensure that the HTML is correct! So there is some work needed from you before it will work.
Avatar billede txk Nybegynder
24. marts 2002 - 12:54 #15
i have fixed it now terry you were all most right
Avatar billede txk Nybegynder
24. marts 2002 - 12:55 #16
just forgot 1 line but all the other stuff were right...

Tak
Avatar billede terry Ekspert
24. marts 2002 - 16:08 #17
selv tak :o)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester