Discusman
asked on
How to create a discussion forum on my web site?
Hi,
I would like to have a discussion forum running on my web site. User would be able to post, view and reply messages on my site. Currently I'm running IIS 5.1 in windows XP Pro. My web pages are based on ASP. I have seen many discussion forums running in PHP out there. Could I use ASP with HTML create discussion forum as well? If possible, could someone basic examples and codings on how to create it? Thanks in advance.
I would like to have a discussion forum running on my web site. User would be able to post, view and reply messages on my site. Currently I'm running IIS 5.1 in windows XP Pro. My web pages are based on ASP. I have seen many discussion forums running in PHP out there. Could I use ASP with HTML create discussion forum as well? If possible, could someone basic examples and codings on how to create it? Thanks in advance.
Yes you can use ASP with html to built a Strong message Board. Take a look on the following link.it will give you a basic overview.
http://www.troutflap.clara.net/Attack/Monkeypages/messageboard.htm
http://www.troutflap.clara.net/Attack/Monkeypages/messageboard.htm
ASKER
Hi mmongeon,
I would like to learn how to create a forum by writing the codes, not just using someone else product. Thanks anyway.
I would like to learn how to create a forum by writing the codes, not just using someone else product. Thanks anyway.
ASKER
Hi adilkhan,
Your example is similar to my guestbook ASP page. It allows user to post message, view and reply to the site. As you know, Access only allow 255 chars per field. That means I need to have a text file as my database. Therefore, user will be able to write a long essay in the forum. I would like to create some basic functions which most forums suppose to have. For example, 1st page of the forum should be the listing of all subject of individual post. When user click on the subject, the program should bring the user to the page which display the content of the post. There should be a "Reply" button at the button of the page. Any replies should be go directly to this post. I dont know how to do this. Plz help. Thanks.
Your example is similar to my guestbook ASP page. It allows user to post message, view and reply to the site. As you know, Access only allow 255 chars per field. That means I need to have a text file as my database. Therefore, user will be able to write a long essay in the forum. I would like to create some basic functions which most forums suppose to have. For example, 1st page of the forum should be the listing of all subject of individual post. When user click on the subject, the program should bring the user to the page which display the content of the post. There should be a "Reply" button at the button of the page. Any replies should be go directly to this post. I dont know how to do this. Plz help. Thanks.
ASKER
Hi adilkhan,
I just realized that set the field type to Memo would allow unlimitied number of chars entered in the field. That's great! I need to test it out. Thanks.
I just realized that set the field type to Memo would allow unlimitied number of chars entered in the field. That's great! I need to test it out. Thanks.
yes I was about to Post about the memo field in access.
basicly thats the Trick behing message boards.
Suppose you have two fields in access
1. Question ID
2. Follow Up
now when some1 posts a question they should insert a uniqe Id number into Database for example 223.
Now lets say someone wants to reply for this question. For this YOu need to stick the same Question ID(223) into the follow Up field.
so SQL statment would be something like this
Select * from table where followUP=223 AND questionID=223
this will pull out the question #223 and also follow ups for 223.
hopt it makes more sense.
basicly thats the Trick behing message boards.
Suppose you have two fields in access
1. Question ID
2. Follow Up
now when some1 posts a question they should insert a uniqe Id number into Database for example 223.
Now lets say someone wants to reply for this question. For this YOu need to stick the same Question ID(223) into the follow Up field.
so SQL statment would be something like this
Select * from table where followUP=223 AND questionID=223
this will pull out the question #223 and also follow ups for 223.
hopt it makes more sense.
www.webwizguide.com
Has a good forum that I use on my site, with some modifications. I learned quite a bit from his programming techniques.
Good Luck!
Has a good forum that I use on my site, with some modifications. I learned quite a bit from his programming techniques.
Good Luck!
ASKER
Ok, I basically have set up the forum on my site. Now I stuck. Plz help. I want user be able to click on the subject link in order to go to the full content of this particular post. I dont know how to do that. The forum lists all the messages by "subject", "PostBy", "PostTime". I didn't make it show the content of each message because the body is too long. Therefore, user should be able to the subject line and the program should bring the body page up. How can I make that subject line as a link?
For example:
The subject is: How can I be a programmer?
when user click on "How can I be a programmer?". The other page should be loaded and shows the complete content of that particular post. Can someone help? Thanks in advance.
For example:
The subject is: How can I be a programmer?
when user click on "How can I be a programmer?". The other page should be loaded and shows the complete content of that particular post. Can someone help? Thanks in advance.
Thats pretty simple to do.
Lets say in Database you have the subject and body field and a unique ID for that question. then you need to make a new page and pass the ID of that question to that new page. example
<a href="show_body.asp?id=<%= rs("id")%> ">How Can I be a Programmer</a>
now on the show_body.asp page you need to grab the value of id variable like this
id = request("id")
then write your Sql statement
select * from table_name where id_num=id
this will select that record set which contains the Id of your Clicked question. Then You can print out the body field on the new Page.
if it sounds confusing to you Let me know.
Lets say in Database you have the subject and body field and a unique ID for that question. then you need to make a new page and pass the ID of that question to that new page. example
<a href="show_body.asp?id=<%=
now on the show_body.asp page you need to grab the value of id variable like this
id = request("id")
then write your Sql statement
select * from table_name where id_num=id
this will select that record set which contains the Id of your Clicked question. Then You can print out the body field on the new Page.
if it sounds confusing to you Let me know.
ASKER
Hi adikhan,
I know what u saying but the way I list all the subjects of the post is different from you described above. Here is part of code for display all the subjects by using a loop.
========================== =========
strSQL = "SELECT Subject, UserName, PostTime FROM Thread"
objRS.Open strSQL,objConnection,3,3
Response.Write "Post List" & _
"<TABLE BORDER=1 cellpadding=2 cellspacing=2>" & _
"<TR>" & _
"<TH>Subject</TH>" & _
"<TH>Post By</TH>" & _
"<TH>Post Date</TH>" & _
"</TR>"
for i=1 to objRS.RecordCount
Response.Write("<TR>")
for j=0 to objRS.Fields.count-1
Response.Write("<TD>" & objRS(j).Value & "</TD>")
next
Response.Write("</TR>")
objRS.MoveNext
next
Response.Write("</Table>")
========================== ========== ========== ====
As you can see objRS(j) is the recordset to display all the subjects in the table. objRS(j) displays all the records by showing "subject", "PostBy", "PostTime". I used SQL statement such as "Select subject,Postby,PostTime From TableName. How can you make it the only subject clickable? I know it's not going to work if I do this:
<a href="show_body.asp?id=<%= rs("id")%> ">objRS(j) </a>
I know what u saying but the way I list all the subjects of the post is different from you described above. Here is part of code for display all the subjects by using a loop.
==========================
strSQL = "SELECT Subject, UserName, PostTime FROM Thread"
objRS.Open strSQL,objConnection,3,3
Response.Write "Post List" & _
"<TABLE BORDER=1 cellpadding=2 cellspacing=2>" & _
"<TR>" & _
"<TH>Subject</TH>" & _
"<TH>Post By</TH>" & _
"<TH>Post Date</TH>" & _
"</TR>"
for i=1 to objRS.RecordCount
Response.Write("<TR>")
for j=0 to objRS.Fields.count-1
Response.Write("<TD>" & objRS(j).Value & "</TD>")
next
Response.Write("</TR>")
objRS.MoveNext
next
Response.Write("</Table>")
==========================
As you can see objRS(j) is the recordset to display all the subjects in the table. objRS(j) displays all the records by showing "subject", "PostBy", "PostTime". I used SQL statement such as "Select subject,Postby,PostTime From TableName. How can you make it the only subject clickable? I know it's not going to work if I do this:
<a href="show_body.asp?id=<%=
Discusman , Are you trying to get all the fields out of your database then Try using the 'While loop' and get rid of for and nested FOR loops.Example
<%
while not rs.eof
%>
<a href="show.asp?id=<%=rs("i d")%>">Sub ject</a>
<%
rs.movenext
wend
%>
<%
while not rs.eof
%>
<a href="show.asp?id=<%=rs("i
<%
rs.movenext
wend
%>
by using the while LOOP you dont need to use a variable to keep track of records you can actualy define which record you want to select. For example if 'ID' is the field in Access and 'rs' is the instance name of your recordset object then you just say rs("id") or same for rs("subject") for the subject field.
ASKER
Ok, here is what I want to do.
I have those fields in my database. "ThreadID", "Subject", "Body", "PostTime", "PostBy".
I want to display all the records in that database by showing "Subject", "PostTime" and "PostBy" on my form.
The subject should be clickable, so user will be able to view the content under that particular subject after they clicked on the subject.
By the way, what's that wend mean in ur example code? Thanks.
I have those fields in my database. "ThreadID", "Subject", "Body", "PostTime", "PostBy".
I want to display all the records in that database by showing "Subject", "PostTime" and "PostBy" on my form.
The subject should be clickable, so user will be able to view the content under that particular subject after they clicked on the subject.
By the way, what's that wend mean in ur example code? Thanks.
here is the sample Code to pull everything out of your table
' assume conn is a connection object
' assume rs is the recordset object
sql = "Select * from table_name"
rs.open sql,conn
<table>
<tr>
<td>Id</td>
<td>Subject</td>
<td>Time</td>
</tr>
<% while not rs.eof %>
' this while means if rs is not equall to end of file
<tr>
<td><%=rs("ThreadID")%></t d>
' <%=%> is same is response.write
<td><a href="show.asp?tid=<%=rs(" ThreadID") %>"><%=rs( "subject") %></td>
<td><%=rs("PostTime")%></t d>
</tr>
<%
rs.movenext
' as we defined a while loop it will move to the next record
wend
' wend means END the While Loop
%>
</table>
now on the show the asp page.
grab the value of Clicked subject
which_Subject = request("tid")
'tid was the name of queryString Variable on first page.
so on show.asp page use the following sql
sql = select * from table_name where id="&which_subject
once you select that record simply pull out the values by doing the same process.
' assume conn is a connection object
' assume rs is the recordset object
sql = "Select * from table_name"
rs.open sql,conn
<table>
<tr>
<td>Id</td>
<td>Subject</td>
<td>Time</td>
</tr>
<% while not rs.eof %>
' this while means if rs is not equall to end of file
<tr>
<td><%=rs("ThreadID")%></t
' <%=%> is same is response.write
<td><a href="show.asp?tid=<%=rs("
<td><%=rs("PostTime")%></t
</tr>
<%
rs.movenext
' as we defined a while loop it will move to the next record
wend
' wend means END the While Loop
%>
</table>
now on the show the asp page.
grab the value of Clicked subject
which_Subject = request("tid")
'tid was the name of queryString Variable on first page.
so on show.asp page use the following sql
sql = select * from table_name where id="&which_subject
once you select that record simply pull out the values by doing the same process.
ASKER
Ok, I will test it when I get home tonight. Thanks.
ASKER
By the way, I have a question regarding the reply button. When user wants to reply particular post on the form. Is it going to be a new record inserted to the table or just adding more text into that post which the user reply to?
For example, when user wants to reply post #2 in the table. The reply text will be added into post #2 or is it going to be a new record inserted to the table?
For example, when user wants to reply post #2 in the table. The reply text will be added into post #2 or is it going to be a new record inserted to the table?
Reply Could be inserted into a new record(ROW) BUT you do need to track it. for example ID for question # 2 is lets say '2', then for the reply field you need to have ParentID number(which is 2) as well. So you can select all the replies by writing a simplw SQL query.
select * from table where id = 2
this will pull out all the replies and the question as well.
select * from table where id = 2
this will pull out all the replies and the question as well.
ASKER
Ok, so you mean all the reply text will be added in post #2. Then how would you display each reply separately within a table?
Remember the While LOOP?. use the same While loop to pull everything out of database that has instance of that question ID. Make your Table and display the Main question on the very top level Table Cell then create another recordset(rs) instance and write the sql statment to pull everything out and use the while loop on the replies.
by the way for only 20 ponits its to much help i am providing you.
by the way for only 20 ponits its to much help i am providing you.
ASKER
Yeah, I know. But I am really new in ASP and I am not rich either. I appreciate your big help. I'm doing the web site for fun, it's not required by my employer or for commercial use. That's why I only put 20 points on it. Thanks again for your help and I won't ask anymore questions if you think 20 points isn't enough for ur time n effort.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
umm... I just had an internet connection problem. I need to try the ASP tonight. But let me give u the points right now. Thanks.
ASKER
Hey adilkhan,
As you noticed I posted this question twice. If you can post something in my other post. You will have that other 20 points. Otherwise, it would just wasted.
As you noticed I posted this question twice. If you can post something in my other post. You will have that other 20 points. Otherwise, it would just wasted.
The snitz forums are easy, free and work very well.
http://forum.snitz.com/