function sqlQuery($query) { global $sqlResource; global $disableSQLAdd; writeDebugString($query); $result = mysql_query($query) or die(mysql_error($sqlResource)); return $result; }
function sqlGetToolTypes() { $query = "SELECT * FROM TOOL_TYPES;"; $result = sqlQuery($query); $idx = 0; while ($row = mysql_fetch_assoc($result)) { $toolType = $row['Type']; writeDebugString($toolType, ""); $toolTypes[$idx] = $toolType; $idx++; } return $toolTypes; }
function sqlUpdateToolUsage() { global $toolUsageUpdateBeginDelimiter, $toolUsageUpdateEndDelimiter; $updateStore = $_POST['toolUpdateStore']; writeDebugString("Update tool usage called", ""); writeDebugString("From Post", $updateStore); $updatedToolValues = getValues($updateStore, $toolUsageUpdateBeginDelimiter, $toolUsageUpdateEndDelimiter); $numUpdatedToolRows = count($updatedToolValues); writeDebugString("Number of tools that need update", $numUpdatedToolRows); for ($idx = 0; $idx < $numUpdatedToolRows; $idx++) { $autoIdx = 0; $updatedToolRow = $updatedToolValues[$idx]; $updatedToolUsagePartNumber = $updatedToolRow[$autoIdx++]; $updatedToolInStore = $updatedToolRow[$autoIdx++]; $updatedToolInUse = $updatedToolRow[$autoIdx++]; $query = "UPDATE TOOLS SET QuantityInStore='$updatedToolInStore', QuantityInUse='$updatedToolInUse' WHERE PartNumber = '$updatedToolUsagePartNumber';"; $result = sqlQuery($query); } }
<?php print("<div id=\"$frmToolUsageUpdateName\" style=\"display:$defaultDivStyle\">\n"); print("<form action=\"$frmAction?UpdateToolUsage=true\" method=\"post\" onSubmit = \"return updateToolAndSubmit()\";>\n"); print("<table border=\"0\">\n"); print("<h3>Tools added in the database:</h3>"); $numTools = count($toolUsageRows); writeDebugString($numTools, ""); print("<tr class = \"first\">\n"); print("<td class = \"toolUsagePartNumber\">Tool Part Number</td>\n"); print("<td>Quantity In Store </td>\n"); print("<td>Quantity In Use </td>\n"); print("</tr>\n"); for ($idx = 0; $idx < $numTools; $idx++) { $numParams = count($toolUsageRows[$idx]); if ($idx % 2 == 0) { $class = "even"; } else { $class = "odd"; } print("<tr class = \"$class\">"); for ($paramIdx = 0; $paramIdx < $numParams; $paramIdx++) { if ($paramIdx == 0) { print("<td class = \"toolUsagePartNumber\">\n"); } else { print("<td>\n"); } if ($paramIdx == 1) { $name = $toolUsageRows[$idx][0] . $inStoreSuffix;