PDO CRUD Select 编辑框未显示所有枚举值
PDO CRUD Select Box not showing all Enum Values on EDIT
我开发了一个应用程序,用于在我的工作场所创建计算机维修工作卡。
我可以将数据提交到我的 MySQL 数据库并且运行良好。它保存数据并向管理员和客户发送一封电子邮件,其中包含生成的工作卡号,该卡号是 MySQL 中的 AUTOINCREMENT INT。将信息保存到数据库后,您将返回到显示所有已保存信息的 table(我正在使用 JQuery Datadables 和 Bootstrap 5)下面是维修概述的屏幕截图:
Repairs Overview Image
当我点击绿色的VIEW |编辑按钮,它将我带到 editrepairs.php 页面,该页面按照下图预期的那样填充该特定工作卡的数据:
Edit Repairs Image
除了一个问题...一些字段是下拉列表。此示例中的其中一项是“当前状态”。我用来从 MySQL 检索存储的 ENUM 值的代码如下:
<?php
//Select / Foreach function
$smt = $db->prepare('select DISTINCT current_status From repairs WHERE job_number=:job_number');
$smt->bindParam(':job_number',$job_number,PDO::PARAM_STR);
$smt->execute();
$data = $smt->fetchAll();
?>
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status">
<?php foreach ($data as $row): ?>
<option><?=$row["current_status"]?></option>
<?php endforeach ?>
</select>
</div>
</div>
以上仅显示添加工作卡时保存的值。因此,当我在进行维修时需要更改维修状态时,我不能,因为它只显示 1 个单一值...
No Other Options to Select Screen Shot
我的 Table 名称是 repairs,我的专栏名称是 current_status,ENUM 值是 待定、进行中、暂停需要备件、暂停其他故障 和 修复完成
我如何才能像当前显示的那样首先显示已保存状态,然后还显示其他值,以便我可以在 day/week/month 进行维修时更改状态?
我也试过下面的代码,但它做的事情和我上面解释的完全一样。
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status" class="form-control input-sm">
<?php
$result = $db->query("SELECT current_status FROM repairs WHERE job_number = $job_number");
foreach($result as $options)
{
echo '<option value="'.$options['current_status'].'"';
if($options['current_status']==$job_number)
{
echo ' selected';
}
echo '>'. $options['current_status'] . '</option>'."\n";
}
?>
</select>
</div>
</div>
哦,我的页面顶部有 require_once 'connection.php';用于连接到我的数据库。
所以我的问题的正确答案是
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status">
<option value="1" <?= $current_status === 'Pending' ? 'selected' : '' ?>>Pending</option>
<option value="2" <?= $current_status === 'In Progress' ? 'selected' : '' ?>>In Progress</option>
<option value="3" <?= $current_status === 'On Hold Spares Required' ? 'selected' : '' ?>>On Hold Spares Required</option>
<option value="3" <?= $current_status === 'On Hold Other Fault' ? 'selected' : '' ?>>On Hold Other Fault</option>
</select>
</div>
</div>
根据我的理解,我从 Lawrence 的评论中得知操作员
=== which means Identical
Returns 如果 $x 等于 $y,并且它们是同一类型,则为真。
上面显示了 MySQL 数据库中当前选择的值 PLUS 还允许我选择其他选项,并在按下更新按钮时将其正确保存到数据库中。
PHP 我页面顶部的代码:
<?php
require_once 'connection.php';
session_start();
if(!isset($_SESSION['admin_login'])) //check unauthorize user not direct access in "admindashboard.php" page
{
header("location: index.php");
}
if(isset($_SESSION['employee_login'])) //check employee login user not access in "admin_home.php" page
{
header("location: employeedashboard.php");
}
if(isset($_SESSION['tech_login'])) //check user login user not access in "admin_home.php" page
{
header("location: techdashboard.php");
}
if(isset($_SESSION['admin_login']))
{
?>
<?php
if(isset($_REQUEST['update_id']))
{
try
{
$job_number = $_REQUEST['update_id'];
$select_stmt = $db->prepare('SELECT * FROM repairs WHERE job_number =:job_number');
$select_stmt->bindParam(':job_number',$job_number,PDO::PARAM_STR);
$select_stmt->execute();
$row = $select_stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
}
catch(PDOException $e)
{
$e->getMessage();
}
}
if(isset($_REQUEST['btn_update']))
{
$job_number = $_REQUEST['job_number'];
$date = $_REQUEST['date'];
$client_full_name = filter_var($_REQUEST['client_full_name'], FILTER_SANITIZE_STRING);
$client_email = filter_var($_REQUEST['client_email'], FILTER_SANITIZE_EMAIL);
$client_phone = filter_var($_REQUEST['client_phone'], FILTER_SANITIZE_STRING);
$item_for_repair = filter_var($_REQUEST['item_for_repair'], FILTER_SANITIZE_STRING);
$repair_description = filter_var($_REQUEST['repair_description'], FILTER_SANITIZE_STRING);
$hardware_details = filter_var($_REQUEST['hardware_details'], FILTER_SANITIZE_STRING);
$diagnostic_fee = filter_var($_REQUEST['diagnostic_fee'], FILTER_SANITIZE_STRING);
$tech_assigned = filter_var($_REQUEST['tech_assigned'], FILTER_SANITIZE_STRING);
$current_status = filter_var($_REQUEST['current_status'], FILTER_SANITIZE_STRING);
$technician_notes = filter_var($_REQUEST['technician_notes'], FILTER_SANITIZE_STRING);
$admin_notes = filter_var($_REQUEST['admin_notes'], FILTER_SANITIZE_STRING);
$invoice_status = filter_var($_REQUEST['invoice_status'], FILTER_SANITIZE_STRING);
$invoice_number = filter_var($_REQUEST['invoice_number'], FILTER_SANITIZE_STRING);
{
try
{
if(!isset($errorMsg))
{
$update_stmt=$db->prepare('UPDATE repairs SET job_number=:job_number, date=:date, client_full_name=:client_full_name, client_email=:client_email, client_phone=:client_phone, item_for_repair=:item_for_repair, repair_description=:repair_description, hardware_details=:hardware_details, diagnostic_fee=:diagnostic_fee, tech_assigned=:tech_assigned, current_status=:current_status, technician_notes=:technician_notes, admin_notes=:admin_notes, invoice_status=:invoice_status, invoice_number=:invoice_number WHERE job_number=:job_number');
$update_stmt->bindParam(':job_number', $job_number, PDO::PARAM_INT);
$update_stmt->bindParam(':date', $date);
$update_stmt->bindParam(':client_full_name', $client_full_name, PDO::PARAM_STR);
$update_stmt->bindParam(':client_email', $client_email, PDO::PARAM_STR);
$update_stmt->bindParam(':client_phone', $client_phone, PDO::PARAM_STR);
$update_stmt->bindParam(':item_for_repair', $item_for_repair, PDO::PARAM_STR);
$update_stmt->bindParam(':repair_description',$repair_description, PDO::PARAM_STR);
$update_stmt->bindParam(':hardware_details', $hardware_details, PDO::PARAM_STR);
$update_stmt->bindParam(':diagnostic_fee', $diagnostic_fee, PDO::PARAM_STR);
$update_stmt->bindParam(':tech_assigned', $tech_assigned, PDO::PARAM_STR);
$update_stmt->bindParam(':current_status', $current_status, PDO::PARAM_STR);
$update_stmt->bindParam(':technician_notes', $technician_notes, PDO::PARAM_STR);
$update_stmt->bindParam(':admin_notes', $admin_notes, PDO::PARAM_STR);
$update_stmt->bindParam(':invoice_status', $invoice_status, PDO::PARAM_STR);
$update_stmt->bindParam(':invoice_number', $invoice_number, PDO::PARAM_STR);
if($update_stmt->execute())
{
$updateMsg="Record Update Successfully. Refreshing in 3 seconds.";
header("refresh:3;repairs.php");
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
}
?>
和我的表格(在同一页面上)
<!-- first row starts here -->
<?php
if(isset($errorMsg)){
?>
<div class="alert alert-danger">
<strong>ERROR ! <?php echo $errorMsg; ?></strong>
</div>
<?php
}
if(isset($updateMsg)){
?>
<div class="alert alert-success">
<strong>UPDATED ! <?php echo $updateMsg; ?></strong>
</div>
<?php
}
?>
<form method="post" name="form" id="form" class="form form-horizontal" action="">
<div class="form-group">
<label class="col-sm-3 control-label">Job Number</label>
<div class="col-sm-12">
<input type="text" name="job_number" class="form-control" value="<?php echo $job_number; ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Date Repair Booked in</label>
<div class="col-sm-12">
<input type="date" name="date" class="form-control" value="<?php echo $date; ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Client Full Name</label>
<div class="col-sm-12">
<input type="text" name="client_full_name" class="form-control" value="<?php echo $client_full_name; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Client Email</label>
<div class="col-sm-12">
<input type="text" name="client_email" class="form-control" value="<?php echo $client_email; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Client Phone Number</label>
<div class="col-sm-12">
<input type="text" name="client_phone" class="form-control" value="<?php echo $client_phone; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Item For Repair</label>
<div class="col-sm-12">
<select name="item_for_repair" id="item_for_repair">
<option value="1" <?= $item_for_repair === 'Laptop' ? 'selected' : '' ?>>Laptop</option>
<option value="2" <?= $item_for_repair === 'Desktop' ? 'selected' : '' ?>>Desktop</option>
<option value="3" <?= $item_for_repair === 'Television' ? 'selected' : '' ?>>Television</option>
<option value="4" <?= $item_for_repair === 'Washing Machine' ? 'selected' : '' ?>>Washing Machine</option>
<option value="5" <?= $item_for_repair === 'Tumble Dryer' ? 'selected' : '' ?>>Tumble Dryer</option>
<option value="6" <?= $item_for_repair === 'Dishwasher' ? 'selected' : '' ?>>Dishwasher</option>
<option value="7" <?= $item_for_repair === 'Microwave' ? 'selected' : '' ?>>Microwave</option>
<option value="8" <?= $item_for_repair === 'Fridge' ? 'selected' : '' ?>>Fridge</option>
<option value="9" <?= $item_for_repair === 'Printer' ? 'selected' : '' ?>>Printer</option>
<option value="10" <?= $item_for_repair === 'Other' ? 'selected' : '' ?>>Other</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Repair Description</label>
<div class="col-sm-12">
<input type="text" name="repair_description" class="form-control" value="<?php echo $repair_description; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Hardware Details</label>
<div class="col-sm-12">
<input type="text" name="hardware_details" class="form-control" value="<?php echo $hardware_details; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Diagnostic Fee</label>
<div class="col-sm-12">
<input type="text" name="diagnostic_fee" class="form-control" value="<?php echo $diagnostic_fee; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Technician Assigned</label>
<div class="col-sm-12">
<select name="tech_assigned" id="tech_assigned">
<option value="1" <?= $tech_assigned === 'Brendon' ? 'selected' : '' ?>>Brendon</option>
<option value="2" <?= $tech_assigned === 'Gabriel' ? 'selected' : '' ?>>Gabriel</option>
<option value="3" <?= $tech_assigned === 'Jami' ? 'selected' : '' ?>>Jami</option>
<option value="4" <?= $tech_assigned === 'Lee-Roy' ? 'selected' : '' ?>>Lee-Roy</option>
<option value="5" <?= $tech_assigned === 'Conrad' ? 'selected' : '' ?>>Conrad</option>
<option value="6" <?= $tech_assigned === 'Tapiwa' ? 'selected' : '' ?>>Tapiwa</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status">
<option value="1" <?= $current_status === 'Pending' ? 'selected' : '' ?>>Pending</option>
<option value="2" <?= $current_status === 'In Progress' ? 'selected' : '' ?>>In Progress</option>
<option value="3" <?= $current_status === 'On Hold Spares Required' ? 'selected' : '' ?>>On Hold Spares Required</option>
<option value="3" <?= $current_status === 'On Hold Other Fault' ? 'selected' : '' ?>>On Hold Other Fault</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Technician Notes</label>
<div class="col-sm-12">
<input type="text" name="technician_notes" class="form-control" value="<?php echo $technician_notes; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Admin Notes</label>
<div class="col-sm-12">
<input type="text" name="admin_notes" class="form-control" value="<?php echo $admin_notes; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Invoice Status</label>
<div class="col-sm-12">
<select name="invoice_status" id="invoice_status">
<option value="1" <?= $invoice_status === 'Client Not Invoiced Yet' ? 'selected' : '' ?>>Client Not Invoiced Yet</option>
<option value="2" <?= $invoice_status === 'Client Invoiced' ? 'selected' : '' ?>>Client Invoiced</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Invoice Number</label>
<div class="col-sm-12">
<input type="text" name="invoice_number" class="form-control" value="<?php echo $invoice_number; ?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9 m-t-15">
<input type="submit" name="btn_update" class="btn btn-primary" value="Update">
<a href="repairs.php" class="btn btn-danger">Cancel</a>
</div>
</div>
</form>
我在没有互联网连接的本地机器上使用它,所以我知道我的代码中存在一些安全问题,但由于无法从外部访问该应用程序,所以我不介意在安全方面有所失误。但我会继续努力,然后回来 post 我的新代码在这里更新 PDO/PHP 安全措施
我开发了一个应用程序,用于在我的工作场所创建计算机维修工作卡。
我可以将数据提交到我的 MySQL 数据库并且运行良好。它保存数据并向管理员和客户发送一封电子邮件,其中包含生成的工作卡号,该卡号是 MySQL 中的 AUTOINCREMENT INT。将信息保存到数据库后,您将返回到显示所有已保存信息的 table(我正在使用 JQuery Datadables 和 Bootstrap 5)下面是维修概述的屏幕截图:
Repairs Overview Image
当我点击绿色的VIEW |编辑按钮,它将我带到 editrepairs.php 页面,该页面按照下图预期的那样填充该特定工作卡的数据:
Edit Repairs Image
除了一个问题...一些字段是下拉列表。此示例中的其中一项是“当前状态”。我用来从 MySQL 检索存储的 ENUM 值的代码如下:
<?php
//Select / Foreach function
$smt = $db->prepare('select DISTINCT current_status From repairs WHERE job_number=:job_number');
$smt->bindParam(':job_number',$job_number,PDO::PARAM_STR);
$smt->execute();
$data = $smt->fetchAll();
?>
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status">
<?php foreach ($data as $row): ?>
<option><?=$row["current_status"]?></option>
<?php endforeach ?>
</select>
</div>
</div>
以上仅显示添加工作卡时保存的值。因此,当我在进行维修时需要更改维修状态时,我不能,因为它只显示 1 个单一值...
No Other Options to Select Screen Shot
我的 Table 名称是 repairs,我的专栏名称是 current_status,ENUM 值是 待定、进行中、暂停需要备件、暂停其他故障 和 修复完成
我如何才能像当前显示的那样首先显示已保存状态,然后还显示其他值,以便我可以在 day/week/month 进行维修时更改状态?
我也试过下面的代码,但它做的事情和我上面解释的完全一样。
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status" class="form-control input-sm">
<?php
$result = $db->query("SELECT current_status FROM repairs WHERE job_number = $job_number");
foreach($result as $options)
{
echo '<option value="'.$options['current_status'].'"';
if($options['current_status']==$job_number)
{
echo ' selected';
}
echo '>'. $options['current_status'] . '</option>'."\n";
}
?>
</select>
</div>
</div>
哦,我的页面顶部有 require_once 'connection.php';用于连接到我的数据库。
所以我的问题的正确答案是
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status">
<option value="1" <?= $current_status === 'Pending' ? 'selected' : '' ?>>Pending</option>
<option value="2" <?= $current_status === 'In Progress' ? 'selected' : '' ?>>In Progress</option>
<option value="3" <?= $current_status === 'On Hold Spares Required' ? 'selected' : '' ?>>On Hold Spares Required</option>
<option value="3" <?= $current_status === 'On Hold Other Fault' ? 'selected' : '' ?>>On Hold Other Fault</option>
</select>
</div>
</div>
根据我的理解,我从 Lawrence 的评论中得知操作员
=== which means Identical
Returns 如果 $x 等于 $y,并且它们是同一类型,则为真。
上面显示了 MySQL 数据库中当前选择的值 PLUS 还允许我选择其他选项,并在按下更新按钮时将其正确保存到数据库中。
PHP 我页面顶部的代码:
<?php
require_once 'connection.php';
session_start();
if(!isset($_SESSION['admin_login'])) //check unauthorize user not direct access in "admindashboard.php" page
{
header("location: index.php");
}
if(isset($_SESSION['employee_login'])) //check employee login user not access in "admin_home.php" page
{
header("location: employeedashboard.php");
}
if(isset($_SESSION['tech_login'])) //check user login user not access in "admin_home.php" page
{
header("location: techdashboard.php");
}
if(isset($_SESSION['admin_login']))
{
?>
<?php
if(isset($_REQUEST['update_id']))
{
try
{
$job_number = $_REQUEST['update_id'];
$select_stmt = $db->prepare('SELECT * FROM repairs WHERE job_number =:job_number');
$select_stmt->bindParam(':job_number',$job_number,PDO::PARAM_STR);
$select_stmt->execute();
$row = $select_stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
}
catch(PDOException $e)
{
$e->getMessage();
}
}
if(isset($_REQUEST['btn_update']))
{
$job_number = $_REQUEST['job_number'];
$date = $_REQUEST['date'];
$client_full_name = filter_var($_REQUEST['client_full_name'], FILTER_SANITIZE_STRING);
$client_email = filter_var($_REQUEST['client_email'], FILTER_SANITIZE_EMAIL);
$client_phone = filter_var($_REQUEST['client_phone'], FILTER_SANITIZE_STRING);
$item_for_repair = filter_var($_REQUEST['item_for_repair'], FILTER_SANITIZE_STRING);
$repair_description = filter_var($_REQUEST['repair_description'], FILTER_SANITIZE_STRING);
$hardware_details = filter_var($_REQUEST['hardware_details'], FILTER_SANITIZE_STRING);
$diagnostic_fee = filter_var($_REQUEST['diagnostic_fee'], FILTER_SANITIZE_STRING);
$tech_assigned = filter_var($_REQUEST['tech_assigned'], FILTER_SANITIZE_STRING);
$current_status = filter_var($_REQUEST['current_status'], FILTER_SANITIZE_STRING);
$technician_notes = filter_var($_REQUEST['technician_notes'], FILTER_SANITIZE_STRING);
$admin_notes = filter_var($_REQUEST['admin_notes'], FILTER_SANITIZE_STRING);
$invoice_status = filter_var($_REQUEST['invoice_status'], FILTER_SANITIZE_STRING);
$invoice_number = filter_var($_REQUEST['invoice_number'], FILTER_SANITIZE_STRING);
{
try
{
if(!isset($errorMsg))
{
$update_stmt=$db->prepare('UPDATE repairs SET job_number=:job_number, date=:date, client_full_name=:client_full_name, client_email=:client_email, client_phone=:client_phone, item_for_repair=:item_for_repair, repair_description=:repair_description, hardware_details=:hardware_details, diagnostic_fee=:diagnostic_fee, tech_assigned=:tech_assigned, current_status=:current_status, technician_notes=:technician_notes, admin_notes=:admin_notes, invoice_status=:invoice_status, invoice_number=:invoice_number WHERE job_number=:job_number');
$update_stmt->bindParam(':job_number', $job_number, PDO::PARAM_INT);
$update_stmt->bindParam(':date', $date);
$update_stmt->bindParam(':client_full_name', $client_full_name, PDO::PARAM_STR);
$update_stmt->bindParam(':client_email', $client_email, PDO::PARAM_STR);
$update_stmt->bindParam(':client_phone', $client_phone, PDO::PARAM_STR);
$update_stmt->bindParam(':item_for_repair', $item_for_repair, PDO::PARAM_STR);
$update_stmt->bindParam(':repair_description',$repair_description, PDO::PARAM_STR);
$update_stmt->bindParam(':hardware_details', $hardware_details, PDO::PARAM_STR);
$update_stmt->bindParam(':diagnostic_fee', $diagnostic_fee, PDO::PARAM_STR);
$update_stmt->bindParam(':tech_assigned', $tech_assigned, PDO::PARAM_STR);
$update_stmt->bindParam(':current_status', $current_status, PDO::PARAM_STR);
$update_stmt->bindParam(':technician_notes', $technician_notes, PDO::PARAM_STR);
$update_stmt->bindParam(':admin_notes', $admin_notes, PDO::PARAM_STR);
$update_stmt->bindParam(':invoice_status', $invoice_status, PDO::PARAM_STR);
$update_stmt->bindParam(':invoice_number', $invoice_number, PDO::PARAM_STR);
if($update_stmt->execute())
{
$updateMsg="Record Update Successfully. Refreshing in 3 seconds.";
header("refresh:3;repairs.php");
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
}
?>
和我的表格(在同一页面上)
<!-- first row starts here -->
<?php
if(isset($errorMsg)){
?>
<div class="alert alert-danger">
<strong>ERROR ! <?php echo $errorMsg; ?></strong>
</div>
<?php
}
if(isset($updateMsg)){
?>
<div class="alert alert-success">
<strong>UPDATED ! <?php echo $updateMsg; ?></strong>
</div>
<?php
}
?>
<form method="post" name="form" id="form" class="form form-horizontal" action="">
<div class="form-group">
<label class="col-sm-3 control-label">Job Number</label>
<div class="col-sm-12">
<input type="text" name="job_number" class="form-control" value="<?php echo $job_number; ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Date Repair Booked in</label>
<div class="col-sm-12">
<input type="date" name="date" class="form-control" value="<?php echo $date; ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Client Full Name</label>
<div class="col-sm-12">
<input type="text" name="client_full_name" class="form-control" value="<?php echo $client_full_name; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Client Email</label>
<div class="col-sm-12">
<input type="text" name="client_email" class="form-control" value="<?php echo $client_email; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Client Phone Number</label>
<div class="col-sm-12">
<input type="text" name="client_phone" class="form-control" value="<?php echo $client_phone; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Item For Repair</label>
<div class="col-sm-12">
<select name="item_for_repair" id="item_for_repair">
<option value="1" <?= $item_for_repair === 'Laptop' ? 'selected' : '' ?>>Laptop</option>
<option value="2" <?= $item_for_repair === 'Desktop' ? 'selected' : '' ?>>Desktop</option>
<option value="3" <?= $item_for_repair === 'Television' ? 'selected' : '' ?>>Television</option>
<option value="4" <?= $item_for_repair === 'Washing Machine' ? 'selected' : '' ?>>Washing Machine</option>
<option value="5" <?= $item_for_repair === 'Tumble Dryer' ? 'selected' : '' ?>>Tumble Dryer</option>
<option value="6" <?= $item_for_repair === 'Dishwasher' ? 'selected' : '' ?>>Dishwasher</option>
<option value="7" <?= $item_for_repair === 'Microwave' ? 'selected' : '' ?>>Microwave</option>
<option value="8" <?= $item_for_repair === 'Fridge' ? 'selected' : '' ?>>Fridge</option>
<option value="9" <?= $item_for_repair === 'Printer' ? 'selected' : '' ?>>Printer</option>
<option value="10" <?= $item_for_repair === 'Other' ? 'selected' : '' ?>>Other</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Repair Description</label>
<div class="col-sm-12">
<input type="text" name="repair_description" class="form-control" value="<?php echo $repair_description; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Hardware Details</label>
<div class="col-sm-12">
<input type="text" name="hardware_details" class="form-control" value="<?php echo $hardware_details; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Diagnostic Fee</label>
<div class="col-sm-12">
<input type="text" name="diagnostic_fee" class="form-control" value="<?php echo $diagnostic_fee; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Technician Assigned</label>
<div class="col-sm-12">
<select name="tech_assigned" id="tech_assigned">
<option value="1" <?= $tech_assigned === 'Brendon' ? 'selected' : '' ?>>Brendon</option>
<option value="2" <?= $tech_assigned === 'Gabriel' ? 'selected' : '' ?>>Gabriel</option>
<option value="3" <?= $tech_assigned === 'Jami' ? 'selected' : '' ?>>Jami</option>
<option value="4" <?= $tech_assigned === 'Lee-Roy' ? 'selected' : '' ?>>Lee-Roy</option>
<option value="5" <?= $tech_assigned === 'Conrad' ? 'selected' : '' ?>>Conrad</option>
<option value="6" <?= $tech_assigned === 'Tapiwa' ? 'selected' : '' ?>>Tapiwa</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Current Status</label>
<div class="col-sm-12">
<select name="current_status" id="current_status">
<option value="1" <?= $current_status === 'Pending' ? 'selected' : '' ?>>Pending</option>
<option value="2" <?= $current_status === 'In Progress' ? 'selected' : '' ?>>In Progress</option>
<option value="3" <?= $current_status === 'On Hold Spares Required' ? 'selected' : '' ?>>On Hold Spares Required</option>
<option value="3" <?= $current_status === 'On Hold Other Fault' ? 'selected' : '' ?>>On Hold Other Fault</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Technician Notes</label>
<div class="col-sm-12">
<input type="text" name="technician_notes" class="form-control" value="<?php echo $technician_notes; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Admin Notes</label>
<div class="col-sm-12">
<input type="text" name="admin_notes" class="form-control" value="<?php echo $admin_notes; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Invoice Status</label>
<div class="col-sm-12">
<select name="invoice_status" id="invoice_status">
<option value="1" <?= $invoice_status === 'Client Not Invoiced Yet' ? 'selected' : '' ?>>Client Not Invoiced Yet</option>
<option value="2" <?= $invoice_status === 'Client Invoiced' ? 'selected' : '' ?>>Client Invoiced</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Invoice Number</label>
<div class="col-sm-12">
<input type="text" name="invoice_number" class="form-control" value="<?php echo $invoice_number; ?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9 m-t-15">
<input type="submit" name="btn_update" class="btn btn-primary" value="Update">
<a href="repairs.php" class="btn btn-danger">Cancel</a>
</div>
</div>
</form>
我在没有互联网连接的本地机器上使用它,所以我知道我的代码中存在一些安全问题,但由于无法从外部访问该应用程序,所以我不介意在安全方面有所失误。但我会继续努力,然后回来 post 我的新代码在这里更新 PDO/PHP 安全措施