Discussion Board - How to create an index of the discussion?
Step 1 – We need to list out all the discussions in a table:
<% Set conn = Server.CreateObject("Adodb.Connection") conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("Adodb.Recordset") rs.open "Discuss",conn,1,3 do while not rs.eof response.write(" " " " " rs.movenext loop rs.close set rs = nothing set conn = nothing %>
User Title Post Date " & _ ") " & rs.fields("User") & " " & _ " & rs.fields("Title") & " " & _ " & rs.fields("PostDate") & " " & _
Step 2 – We need to create a link that will show the details of the discussion.
In the HTML code, we need to create a hyperlink. So we need to use this command:
First, we can use the Looping to create all the links:
First, we understand that each discussion has its own ID, so we can use the ID to identify it.
Now, we can try to create a link like this:
<%=rs.fields("ID")%>’> ‘We can get the ID from the database
The complete example is shown below:
<% Set conn = Server.CreateObject("Adodb.Connection") conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("Adodb.Recordset") rs.open "Discuss",conn,1,3 do while not rs.eof response.write(" " " " " rs.movenext loop rs.close set rs = nothing set conn = nothing %>
User Title Post Date " & _ ") " & rs.fields("User") & " " & _ " & rs.fields("Title") & " " & _ " & rs.fields("PostDate") & " " & _
No comments:
Post a Comment