Ich schreibe eine php-Anwendung, die an eine mySQL-Datenbank senden wird. Ich habe diesen Teil arbeiten, aber ich habe eine Spalte namens repID, die die Kunden Reparatur-ID enthalten wird.
Die Inhalte werden der Datenbank über einen Administrator auf meiner Website hinzugefügt. Ich würde es gerne so einrichten, dass wenn ein Techniker eine bestehende RepID eingibt, nur der Schlüssel für diese aktualisiert wird. Anstatt ein Duplikat mit einem anderen Reparaturstatus zu erstellen
PHP
$repID = mysql_real_escape_string($_POST['repID']);
$clientName = mysql_real_escape_string($_POST['clientName']);
$devModel = mysql_real_escape_string($_POST['devModel']);
$repStatus = mysql_real_escape_string($_POST['repStatus']);
$tracking = mysql_real_escape_string($_POST['tracking']);
$sql = mysql_query("INSERT INTO status (`repID`, `clientName`, `devModel`, `repStatus`, `tracking`) VALUES ('$repID','$clientName','$devModel','$repStatus', '$tracking');");
EINGABE-SEITE
<?php
include_once('../resources/init.php');
$query = "SELECT * FROM status WHERE repStatus != 'Finished';";
$result = mysql_query($query);
$num = mysql_numrows($result);
mysql_close();
$random = rand(1000000000, 9999999999);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Add A Repair</title>
</head>
<body>
<div id="wrapper">
<div id="application">
<div id="randomNum">
<?php echo $random; ?>
</div>
<form method="post" action="insert.php">
<div id="repID">
<label for="repID">Repair ID</label>
<input type="text" name="repID" />
</div>
<div id="clientName">
<label for="clientName">Client Name</label>
<input type="text" name="clientName" />
</div>
<div id="devModel">
<label for="devModel">Device Model</label>
<input type="text" name="devModel" />
</div>
<div id="repStatus">
<label for="repStatus">Repair Status</label>
<select name="repStatus">
<option value="Diagnosis Stage">Diagnosis Stage</option>
<option value="Problem Found">Problem Found</option>
<option value="Possible Solution">Possible Solution</option>
<option value="Parts Ordered">Parts Ordered</option>
<option value="Parts Recieved">Parts Recieved</option>
<option value="Parts/Software Installation Stage">Parts/Software m Installation Stage</option>
<option value="Testing Stage">Testing Stage</option>
<option value="Finished">Finished</option>
</select>
</div>
<div id="tracking">
<label for="tracking">Tracking Number</label>
<input type="text" name="tracking" />
</div>
<div id="submit">
<input type="submit" value="Submit" />
</div>
</form>
<div id="currentClients">
Current Clients
<br /><br />
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th>Repair ID</th>
<th>Client Name</th>
<th>Device Model</th>
<th>Repair Status</th>
<th>Tracking</th>
</tr>
<?php
$i = 0;
while ($i < $num) {
$v1 = mysql_result($result, $i, "repID");
$v2 = mysql_result($result, $i, "clientName");
$v3 = mysql_result($result, $i, "devModel");
$v4 = mysql_result($result, $i, "repStatus");
$v5 = mysql_result($result, $i, "tracking");
?>
<tr>
<td><?php echo $v1; ?></td>
<td><?php echo $v2; ?></td>
<td><?php echo $v3; ?></td>
<td><?php echo $v4; ?></td>
<td><?php echo $v5; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
</div>
</div>
</div>
</body>
</html>