Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's assume you are using PHP and MySQL.</p> <p>I will keep this very simple as possible probably need these files in a basic example plus your hopefull explanatory SQL tables (debates, comments, etc).</p> <ul> <li>/debatelist.php | Dipslays all debateshas a form to create a debate</li> <li>/debateprocessor.php | Your 'all in one' data manipulation file.</li> <li>/debate_detail.php | Your detail page where the index of debates points to.</li> </ul> <p><strong>Form to CREATE A DEBATE</strong></p> <pre><code>&lt;form action='debateprocessor.php' action='POST'&gt; &lt;input type='hidden' name='action' value='create'/&gt; &lt;input type='text name='debate_name'/&gt; /// Other inputs - debate topic, debate author, subject etc? same as above &lt;/form&gt; </code></pre> <p>then that would send the form data to debateprocessor.php where we'd sanitize and prepit.</p> <p>$_GET['action']="create" #this tells us we are creating the a debate $_GET['debate_name']="SomeDebate"</p> <p><strong>debateprocessor.php</strong> - you'd want to to pull that in:</p> <pre><code>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'"); } </code></pre> <p>Note the action if($action == 'foo'){ //do something; } statement - this would allow you to handle updates (comments, editing debate names etc) all in one file. other values for action in forms could be 'edit', 'add_comment' etc - you could have separate files to do all this but this allows you to do it all one. All you'd do is add on elseifs or other if statements like above for each action to modify a table.</p> <p>So displaying your debates you'd have something like a master list of debates in a table, say you had </p> <p><strong>debatelist.php</strong></p> <pre><code>&lt;? $getDebates = mysql_query("SELECT * FROM debates";); $rowNum = 0; while($row = mysql_fetch_array($getDebates)) { $thisDebate = $row['debate_name']; $thisDebateID = $row['debate_id'];; echo " &lt;tr&gt; &lt;td&gt; &lt;a href='debate_detail.php?debateid=$thisDebateID'&gt; $thisDebate &lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; "; $rowNum++; } </code></pre> <p>That would output a list of debate names with a link to ea. debate_detail.php page for a given debate pulled by the PK, debate ID. In that file you'd use a similar combination of SELECT (ONLY USE 'WHERE debate_id = 'xyz' and would likely JOIN tables like comments etc on debate_id='zyx' = debate_id='zyx'.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload