function sqlAddOperation($partOperations, $partID) {
    global $opBeginDelimiter;
    global $opEndDelimiter;
    global $dataDelimiter;
    global $allBeginDelimiters;
    global $toolBeginDelimiter;
    global $progBeginDelimiter;
    global $machineBeginDelimiter;
    global $holderBeginDelimiter;
    global $toolHolderBeginDelimiter;

    if ($partOperations == NULL || $partOperations == "") {
      return;
    }
    
    $operationValues = getValues($partOperations, $opBeginDelimiter, $opEndDelimiter);
    $opOnlyDataCount = 0;
    $holderOnlyDataCount = 0;
    $mainProgramId = 0;
    $numOperationValues = count($operationValues);
    $numToolHolderOnlyData = 0;

    for ($idx = 0; $idx < $numOperationValues; $idx++) {
      $operationTokens = $operationValues[$idx];
      $numOpTokens = count($operationTokens);
      for ($curOpToken = 0; $curOpToken < $numOpTokens; $curOpToken++) {
        $beginDelimiter = getBeginDelimiter($operationTokens[$curOpToken]);
        if ($beginDelimiter != "") {
          if ($beginDelimiter == $progBeginDelimiter) {
            $progId = sqlAddProgramForOperation($operationTokens[$curOpToken], $mainProgramId);
              if ($mainProgramId == 0) {
                $mainProgramId = $progId;
              }
          } else if ($beginDelimiter == $toolHolderBeginDelimiter) {
            $toolHolderOnlyData[$numToolHolderOnlyData++] = sqlAddAndGetToolHolderData($operationTokens[$curOpToken]);
	  } else if ($beginDelimiter == $machineBeginDelimiter) {
	    sqlAddMachine($operationTokens[$curOpToken]);
	  }
        } else {
          $operationOnlyData[$opOnlyDataCount++] = $operationTokens[$curOpToken];
        }
      }
      $operationName = $operationOnlyData[0];
      $operationMachineID = $operationOnlyData[1];
      $operationDescription = $operationOnlyData[2];
      $operationCuttingTime = $operationOnlyData[3];
      $operationClampingTime = $operationOnlyData[4];

      $query = "INSERT INTO OPERATIONS (PartID, Name, Machine, Description, CuttingTime, ClampingTime) VALUES ('$partID', '$operationName', '$operationMachineID', '$operationDescription', '$operationCuttingTime', '$operationClampingTime');";  
      $result = sqlQuery($query);
      $opId = mysql_insert_id();

      if (IsSet($toolHolderOnlyData)) {
        $numToolHolderOnlyData = count($toolHolderOnlyData);
        for ($idx = 0; $idx < $numToolHolderOnlyData; $idx++) {
          $toolHolderData = $toolHolderOnlyData[$idx];
          $toolPartNumber = $toolHolderData[0];
  	  $toolId = sqlGetToolIdFromDB($toolPartNumber);
	  $holderName = $toolHolderData[1];
	  $holderId = sqlGetHolderIdFromDB($holderName);
	  $toolRemarks = $toolHolderData[2];
	  $toolOverHang = $toolHolderData[3];
	  $toolLife = $toolHolderData[4];
          $query = "INSERT INTO OPERATION_TOOL_HOLDER_MAPPING (OperationID, ToolID, HolderID, ToolLife, ToolOverHang, ToolRemark) VALUES ('$opId', '$toolId', '$holderId', '$toolLife', '$toolOverHang', '$toolRemark');";
	  $result = sqlQuery($query);
        }
      }
    }
  }
<HTML>
<TITLE>Create/Report Resource</TITLE>
<HEAD>

   <?php
      include ('variables.php');
      include ('commonAPIs.php');
      include ('sqlAPI.php');
      include ('phpDebugAPI.php');
      include ('sqlAddData.php');
      include ('sqlGetData.php');
      sqlConnect("root", "root", "PartsDB");

      if (IsSet($_GET['AddMachine']) && $_GET['AddMachine'] == "true") {
        sqlAddMachine();
      } else if (IsSet($_GET['AddSupplier']) && $_GET['AddSupplier'] == "true") {
        sqlAddSupplierFromPost();
      } else if (IsSet($_GET['AddPart']) && $_GET['AddPart'] == "true") {
        sqlAddPart();
      } else if (IsSet($_GET['AddTool']) && $_GET['AddTool'] == "true") {
        sqlAddToolFromPost();
      } else if (IsSet($_GET['UpdateToolUsage']) && $_GET['UpdateToolUsage'] == "true") {
        sqlUpdateToolUsage();
      }

      
      $machineNames = sqlGetMachines();
      $toolPartNumbers = sqlGetTools();
      $insertPartNumbers = sqlGetInserts();
      $toolTypes = sqlGetToolTypes();
      $holderNames = sqlGetHolders();