Q:

Table structure to store post having reply and reply also having reply using php and Mysql

I am doing  Forum in PHP and Mysql.
i have used the following table structure to store post and reply for post in mysql.From this structure i get the post and reply for that post , but now i am trying to add reply also having   relpy so for that what structure should i use so i store reply also having reply.
Post Table:

post_id    post_title   post_desc 
-----------------------------------------
  1          xyz         sssss
  2          pqr         tyyyu
  3          str         rrrrr
----------------------------------------

Reply_table:

Rep_id    rep_text      post_id
----------------------------------------
  1         gghh           1
  2         uuyu           2
  3         iiooo          1
----------------------------------------

A:

You can add another field to your reply_table named "Parent_ID" where you would store the reply to which is being replied. For example: Let's say Rep_id = 4 is a reply to Rep_1 then
Rep_id    rep_text      post_id     Parent_ID
---------------------------------------------
  1         gghh           1            null
  2         uuyu           2            null
  3         iiooo          1            null
  4         reply to 1     1              1
---------------------------------------------

This way you can have a recursive reply such that then you have have replies to Rep_id = 4
Rep_id    rep_text      post_id     Parent_ID
---------------------------------------------
  1         gghh             1            null
  2         uuyu             2            null
  3         iiooo            1            null
  4         reply to 1       1              1
  5         reply to 4 to 1  1              4
---------------------------------------------

