Suppose you are using PHP and MySQL.
I will keep it as simple as possible, perhaps these files are needed in a basic example plus your reliable SQL explanatory tables (debate, comments, etc.).
- /debatelist.php | Dipslays all debates have the form to create a discussion.
- /debateprocessor.php | Your all-in-one data file.
- /debate_detail.php | A page with detailed information that indicates a debate index.
DISCUSSION CREATION FORM
<form action='debateprocessor.php' action='POST'> <input type='hidden' name='action' value='create'/> <input type='text name='debate_name'/> /// Other inputs - debate topic, debate author, subject etc? same as above </form>
then it will send the form data to the .php discussion processor, where we will sanitize and prefix.
$ _ GET ['action'] = "create" #this tells us that we are creating a discussion $ _GET ['debate_name'] = "SomeDebate"
debateprocessor.php - you want to pull this into:
if (mysql_real_escape_text($_GET['action'])) == 'create'){ $debate_name = mysql_real_escape_text($_GET['debate_name']); //sanitize other variables as above //Insert debate name mysql_query=("INSERT INTO debates (debate_id,debate_name) VALUES ('$debate_name'"); }
Pay attention to the action if ($ action == 'foo') {// do something; } - this will allow you to process updates (comments, edit discussion names, etc.) all in one file. other values ββfor actions in forms can be "edit", "add_comment", etc. - you can have separate files to do all this, but it allows you to do all this. All you need to do is add to elseifs or other if statements, as described above, for each action to modify the table.
So, showing your debate, you will have something like a main debate list in the table, let's say that you have
debatelist.php
<? $getDebates = mysql_query("SELECT * FROM debates";); $rowNum = 0; while($row = mysql_fetch_array($getDebates)) { $thisDebate = $row['debate_name']; $thisDebateID = $row['debate_id'];; echo " <tr> <td> <a href='debate_detail.php?debateid=$thisDebateID'> $thisDebate </a> </td> </tr> "; $rowNum++; }
This will list debate names with a link to ea. debate_detail.php for this discussion by the PC, debate identifier. In this file, you should use a similar combination of SELECT (ONLY USE) WHERE debate_id = 'xyz' and most likely use JOIN tables as comments, etc. On debate_id = 'zyx' = debate_id = 'zyx'.