<?php
//
// lets add the entry to the database here...
//

// get the values that were passed from the form
$name=$_REQUEST["name"];
$date=$_REQUEST["date"];
$month=$_REQUEST["month"];
$year=$_REQUEST["year"];

// connect to the database
@$dbms mysql_connect("localhost","pete","jester");
@
mysql_select_db("movies") or die ("Failed to connect to database: ".mysql_error());

// perform an insert query to add the data
$query "insert into actors (name, dob) values (\"$name\", \"$year-$month-$date\")"
$result mysql_query($query);

?>
<html>
  <head>
    <title>Movie Database</title>
    <style>
      table.movies {
        background-color: #dddddd;
        border: solid 1px #999999;
        border-collapse: collapse;
        border-spacing: 0px;
      }
      table.movies td { padding: 3px; padding-right: 10px; margin: 0px; }
      table.movies th { padding: 3px 5px 3px 3px; text-align: left; margin: 0px; }
      table.movies th.title { font-style: italic; text-align: center; font-size: 150% }
      table.movies td.even { background-color: #ffffff; }
      table.movies td.odd { background-color: #edf3fe; }
    </style>
  </head>
  <body>
<?php
    
// perform a select query. Note the DATE_FORMAT SQL function
    
$query "select name, DATE_FORMAT(dob, \"%d %b %Y\") as dob from actors";
    
$result mysql_query($query);
?>
    <table class="movies">
      <tr>
        <th class="title" colspan="2">Actors</th>
      </tr>
      <tr>
        <th>Name</th>
        <th>Date of Birth</th>
      </tr>
<?php
        $tdclass
="even";
        while (
$line mysql_fetch_array($resultMYSQL_ASSOC)) {
          
$name=$line["name"];
          
$dob=$line["dob"];
          print 
"      <tr>\n";
          print 
"        <td class=\"".$tdclass."\">$name</td>\n";
          print 
"        <td class=\"".$tdclass."\">$dob</td>\n";
          print 
"      </tr>\n";
          if (
$tdclass=="even") { $tdclass "odd"; }
          else { 
$tdclass "even"; }
        }
?>
    </table>
  </body>
</html>