title: Simple PHP task of updating database with radio buttons
body: <p>Front-end designer here, not a PHP developer and I really need the help. Need to make a system that will allow the client to log into their own area to update a table. The table will have about 20 records and each row will be edited with radio buttons (4 choices). Only 2 columns, one for ID and one called status (the editable data). </p>
  
  <p>The viewer will only see the changes made by the client and a background color change to that row depending on the status, which means the editable part will have to hold 2 pieces of data (integer value to change color and the name of the status, e.g. value of the radio button to change color, and label of button to echo the text into the cell). Will deal about login system later...</p>
  
  <p>Database set-up:</p>
  
  <pre><code>Database: test
  Table: fire_alert
  Structure:
     id (INT, PRIMARY); color(INT); warning(VACHAR);
  </code></pre>
  
  <p><code>connect.php</code>:</p>
  
  <pre><code>&lt;?php
  // Database Variables (edit with your own server information)
  $server = 'localhost';
  $user = 'root';
  $pass = 'root';
  $db = 'test';
  
  // Connect to Database
  $connection = mysql_connect($server, $user, $pass) 
      or die("Could not connect to server ... \n" . mysql_error());
  mysql_select_db($db) 
      or die("Could not connect to database ... \n" . mysql_error());
  ?&gt;
  </code></pre>
  
  <p><code>view.php</code>:</p>
  
  <pre><code>&lt;div id="container"&gt;
  &lt;?php
  // connect to the database
  include('connect.php');
  include("header.php");
  
  // get results from database
  $result = mysql_query("SELECT * FROM fire_alert") 
      or die(mysql_error());  
  echo "Current date - " . date("Y/m/d") . "&lt;br /&gt;&lt;br /&gt;";
  
  // display data in table
  echo "&lt;table&gt;";
  echo "&lt;tr&gt; &lt;th&gt;Area&lt;/th&gt; &lt;th&gt;Status&lt;/th&gt;&lt;/tr&gt;";
  
  // loop through results of database query, displaying them in the table
  while($row = mysql_fetch_array($result)) {
      // echo out the contents of each row into a table
      echo "&lt;tr&gt;";
      echo '&lt;td&gt;' . $row['id'] . '&lt;/td&gt;';
      echo '&lt;td&gt;' . $row['warning'] . '&lt;/td&gt;';
      echo "&lt;/tr&gt;"; 
  } 
  
  // close table&gt;
  echo "&lt;/table&gt;";
  
  echo '&lt;td&gt;&lt;a href="edit.php' . $row['id'] . '"&gt;Change Area Status&lt;/a&gt;&lt;/td&gt;';
  ?&gt;
  &lt;/div&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><code>edit.php</code> (client access only) <strong>no</strong> dynamic data changes yet, hardcoded HTML so far:</p>
  
  <pre><code>&lt;?php include("header.php"); ?&gt;
  &lt;?php include("connect.php"); ?&gt;
  
  &lt;div id="container" class="edit"&gt;
  &lt;div id="radio1"&gt;
  
  &lt;?
  $result = mysql_query("SELECT * FROM fire_alert") 
      or die(mysql_error());  
  echo "Current date - " . date("Y/m/d") . "&lt;br /&gt;&lt;br /&gt;";
  ?&gt;
  
  &lt;table class="edit"&gt;
      &lt;tr&gt;&lt;th&gt;Area&lt;/th&gt;&lt;th&gt;Status&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;
              &lt;form method="post" action="edit.php"&gt;
                  &lt;input type="radio" id="radio1" name="radio" value="1" /&gt;&lt;label for="radio1"&gt;Safe&lt;/label&gt;
                  &lt;input type="radio" id="radio2" name="radio" value="2" /&gt;&lt;label for="radio2"&gt;Caution L1&lt;/label&gt;
                  &lt;input type="radio" id="radio3" name="radio" value="3" /&gt;&lt;label for="radio3"&gt;Caution L2&lt;/label&gt;
                  &lt;input type="radio" id="radio4" name="radio" value="4" /&gt;&lt;label for="radio4"&gt;Closed&lt;/label&gt;
              &lt;/form&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/div&gt;
  &lt;?php echo '&lt;td&gt;&lt;a href="view.php' . $row['id'] . '"&gt;Update&lt;/a&gt;&lt;/td&gt;'; ?&gt;
  &lt;/div&gt;
  </code></pre>