Ret forumindlæg
Hej. Jeg har et lukket brugerforum på en hjemmeside, hvor folk kan gå ind og oprette indlæg og besvare dem. Jeg har ikke selv lavet forumet, men blot rettet det til, så jeg skal nok liige ha' lidt hjælp her.Dg gerne vil have lavet er, hvis man har logget sig ind som "Admin", så kan man rette og slette indlæg.
Koden ser således ud nu:
--------------------------------------------------------------
<%
Function besvar(id3)
strSQL2 = "Select * from Forum2 where Id = " & id3
Set rt = Conn.Execute(strSQL2)
c = 0
Do While Not rt.EOF
c = c + 1
rt.moveNext
Loop
Response.write c
End Function
' Databaseforbindelse - husk at angive sti til din database
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("../db/vocal.mdb")
Conn.Open DSN
' SQL forespørgsel
strSQL = "Select Id from Forum1 Order By Id desc"
' Udfør forespørgsel (rs indeholder nu resultatet)
Set rs = Conn.Execute(strSQL)
If not rs.EOF then
top = Rs("Id")
Else
top = 1
End If
If Len(Request.Querystring("Id")) = 0 then
Response.Write "<table><tr><td><table width=""500""align=""left""><tr><td width=""100""><Font id=""v3"">Oversigt</font></td>"
Response.Write "<td width=""100""><a href='indexn.asp?art=forind&id='>Skriv Ny</A></td>"
Response.Write "<td width=""100""><Font id=""v4"">Besvar</font></td></tr></table></td></tr>"
Response.Write "<tr><td><table width=""500"" border=""0"" align=""left"" cellpadding=""1"" cellspacing=""1"">"
Response.Write "<tr bgcolor=""#800000"">"
Response.Write "<td width=""75""><div align=""center"">Dato</div></td>"
Response.Write "<td width=""175""><div align=""center"">Afsender</div></td>"
Response.Write "<td width=""200""><div align=""center"">Overskrift</div></td>"
Response.Write "<td width=""50""><div align=""center"">Svar</div></td>"
Response.Write "</tr>"
strSQL = "Select * from Forum1 order by Id desc"
Set rs = Conn.Execute(strSQL)
Do while not rs.EOF
Dato = Rs("Dato")
Navn = Rs("Afsender")
Over = Rs("Overskrift")
Id = Rs("Id")
Response.Write "<tr>"
Response.Write "<td><div align=""center""><A Href=indexn.asp?art=for&Id=" & Id & ">" & Dato & "</A></div></td>"
Response.Write "<td><div align=""center""><A Href=indexn.asp?art=for&Id=" & Id & ">" & Navn & "</A></div></td>"
Response.Write "<td><div align=""center""><A Href=indexn.asp?art=for&Id=" & Id & ">" & Over & "</A></div></td>"
Response.Write "<td><div align=""center""><A Href=indexn.asp?art=for&Id=" & Id & ">"
besvar(Id)
Response.Write "</A></div></td>"
Response.Write "</tr>"
rs.MoveNext
Loop
Response.Write "</table></td></tr></table>"
'******************************************************************************************
Else
Id = Request.Querystring("Id")
'Response.Write "<br>"
Response.Write "<table><tr><td><table width=""500"" align=""left""><tr><td width=""100""><a href='indexn.asp?art=for'>Oversigt</a></td>"
Response.Write "<td width=""100""><a href='indexn.asp?art=forind&id='>Skriv Ny</A></td>"
Response.Write "<td width=""100""><a href='indexn.asp?art=forind&id=" & id & "'>Besvar</a></td></tr></table><br>"
' SQL forespørgsel
strSQL = "Select * from Forum1 Where Id = " & Id
' Udfør forespørgsel (rs indeholder nu resultatet)
Set rs = Conn.Execute(strSQL)
Dato = Rs("Dato")
Navn = Rs("Afsender")
Over = Rs("Overskrift")
Txt = Rs("Tekst")
Response.Write "<tr><td><table width=""500"" border=""0"" align=""left"" cellpadding=""0"" cellspacing=""0""><tr>"
Response.Write "<td width=""150"" height=""25"" bgcolor=""#800000""><div align=""center"">" & Dato & "</div></td>"
Response.Write "<td width=""310"" height=""25"" bgcolor=""#800000""><div align=""center"">" & Navn & "</div></td>"
Response.Write "</tr><tr>"
Response.Write "<td width=""460"" height=""40"" valign=""top"" colspan=""2""><Font id=""v3"">" & Over & "</font></td>"
Response.Write "</tr><tr>"
Response.Write "<td width=""460"" height=""20"" colspan=""2"">" & txt & "</td>"
Response.Write "</tr><tr>"
Response.Write "<td width=""460"" height=""20"" colspan=""2""> </td></tr>"
' SQL forespørgsel
strSQL = "Select * from Forum2 Where Id = " & Id & " Order by id2"
' Udfør forespørgsel (rs indeholder nu resultatet)
Set rs = Conn.Execute(strSQL)
Do While Not rs.EOF
Dato = Rs("Dato")
Navn = Rs("Afsender")
Over = Rs("Overskrift")
Txt = Rs("Tekst")
Response.Write "<tr>"
Response.Write "<td width=""150"" height=""25"" bgcolor=""#800000""><div align=""center"">" & Dato & "</div></td>"
Response.Write "<td width=""310"" height=""25"" bgcolor=""#800000""><div align=""center"">" & Navn & "</div></td>"
Response.Write "</tr><tr>"
Response.Write "<td width=""460"" height=""40"" valign=""top"" colspan=""2""><Font id=""v3"">" & Over & "</font></td>"
Response.Write "</tr><tr>"
Response.Write "<td width=""460"" height=""20"" colspan=""2"">" & txt & "</td>"
Response.Write "</tr><tr>"
Response.Write "<td width=""460"" height=""20"" colspan=""2""> </td></tr>"
rs.MoveNext
Loop
Response.Write "</table></td></tr></table>"
End If
' Luk databaseforbindelse
Conn.Close
Set Conn = Nothing
%>
---------------------------------------------------------------
Det jeg har brug for er altså en udvidelse hvor:
If Session("adm") = "JA" Then
"mulighed for at rette i beskeder"
Else
"som det er ovenfor"
Jeg ved godt det er et rimeligt omfattende spørgsmål, men det ville altså redde min dag, hvis der var én der lige kunne komme op med en løsning.
Mvh. Claus