Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reply part of a forum

Status
Not open for further replies.

vcherubini

Programmer
May 29, 2000
527
US
I think that this is the last thing that I need for a forum that I am making.

I am working on the part where the user can reply to a post. I have a mySQL table that is called replies. I also have a mySQL table called posts. In the post table, I have an id, user, subject, and message field. Each time the user posts a message, the id field is incremented by one, the subject field gets a value, the user field gets a value, and you guessed it, the messages field does as well. Like I said, I have a replies tables. In the replies table, there is an id, user, subject, and reply field. The same happens with the reply table as the post table each time a user submits a reply.

The problem is pretty hard to explain though, so bear with me. Whenever I submit a reply, the id field is incremented by one, so each reply has a new id value. When I click on a link to see the posts and replies, it will only show one reply at a time because it only calls one id. How can I set up my PHP code/mySQL dbase so that if you have two replies for one post, the id field does not increment until you reply to another post. Is this really confusing?


Any and all help is appreciated.

Thanks a lot,

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
It wouldn't make sense to have a new table for each post and have a reply field and a message field, would it?

I would think that would become quite laborious on the server and create a huge mySQL dbase.

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
" It wouldn't make sense to have a new table for each post and have a reply field and a message field, would it?
I would think that would become quite laborious on the server and create a huge mySQL dbase. "

That would defintely not make sense. Everything you need to do can be handled in a couple of tables, and as mysql can handle several hundred thousand records per table, whilst retaining performance, table size is not really an issue, although you obviously need a bit of extra logic in your php code to retrieve info from the mysql tables.

It sounds like all you need is a 'threadid' field, in both your post and reply tables. This field should not be unique, nor auto increment - a small integer will probaly do as the field type. When you display a reply/post, include the threadid number as a hidden input within the html form, so that this gets posted by the form along with all the other reply info.

Then when it comes to displaying a thread, you can refer to the threadid instead of the unique ID. Andres Jugnarain
Wireless Editor
 
Thanks for the help.
As a matter of fact, I did just that. I added a threadid field so that when you view threads, it sets the variable, then when you input replies to that thread, it stays the same.

Thanks for the help,

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top