<?php
 /* Function addNewType
  * Desc     Adds a new pet type and description to the PpetT type table.
  *          Checks for the new pet type first and does not add it to 
  *          the table if it is already there.
  */
 function addNewType($petType,$typeDescription)
{  
  /* Prepare data */
  $petType = ucfirst(strip_tags(trim($petType)));
  $typeDescription = ucfirst(strip_tags(trim($typeDescription)));

  /* Check whether new category is already in PpetType table. If it 
    is not in table, add it to table. */
  $query = "SELECT petType FROM PpetType WHERE petType='$petType'";
  $result = mysql_query($query) or 
                      die ("Couldn't execute query ");
  $ntype = mysql_num_rows($result); // 
  if ($ntype < 1)  // if new type is not in table
  {
     $query = "INSERT INTO PpetType (petType,typeDescription) 
                             VALUES ('$petType','$typeDescription')";
     $result = mysql_query($query) 
                  or DIE ("Couldn't execute query ");
  }
  return;
}
?>
