Hello,
What's the correct way to implement the below concept via MySQL and PHP? Say a website has two groups/communities, both of which allow its users to ask Questions, answer Questions, and start Discussions, pertaining to the respective community. A user will choose which community he/she wishes to enter via below code(main.php
):
<h2><a href="http://www.domain.com/groupA.php">Group A</a></h2>
<h2><a href="http://www.domain.com/groupB.php">Group B</a></h2>
After the user clicks on say Group B, he/she will of course be directed to groupB.php
, where he/she will be able to view the data related to the Group B community (Questions, Discussions posted by the users etc. ). Of course, one will also be able to do the same for the Group A community.
Now my question is: How can I do this efficiently in MySQL? As of now, say if the user wants to create a discussion/question in Group B, which is located on groupB.php
, he is directed to a form(discussion.php
). Tiny code below:
<form action='savedisc.php' method='post'>
The above form will be available in both communities, i.e. groupA.php
and groupB.php
. Therefore, of course, savedisc.php
will save the content of the form to a database. Meaning, discussion.php
and savedisc.php
will help in saving both groupA.php
and groupB.php
's contents. Some of the savedisc.php
is below:
$sql="INSERT INTO GroupA (Message, Title, Type)
VALUES
('$message','$title','$represents')";
Where GroupA
is the Table's name. The Table name will change of course respective to which group the user may be interacting in. So for group B, the above code will look the same but GroupA
will be replaced by GroupB
. How can I do this in savedisc.php
? Will I have to use numerous IF
statements for various groups?
Given the above steps, is this even possible? Can discussion.php
be located on all community pages? Because then, savedisc.php
's job would be to save contents of groups A, B, C, D in their respective tables within the same database, but the respective group's table. Am I even on the right track?
Thank you.