以我的形式,
到目前为止,我能够在下拉列表中获取数据。但是我无法使用所选值更新数据库。当我提交时,我没有看到任何错误,但数据库没有更新。我是PHP新手,不熟悉所有功能。这是下面的代码:
<?php
$conn = oci_connect("XXX", "XX", "XX");
if (!$conn)
{
$m = oci_error();
echo $m['message'], "\n";
exit;
}
$query = "SELECT ORDERS_ID,TRACKING_NUMBER
FROM TABLE
WHERE ORDERS_ID = :order_bv";
$stid = oci_parse($conn, $query);
if (isset($_POST['order']))
{
$order = $_POST['order'];
}
//$row = oci_fetch_array($stid, OCI_ASSOC);
/* if (!$row) {
//include ('error_page.php');
exit("The order " . $order . " is invalid. Please check and try again" );
} */
oci_bind_by_name($stid, ':order_bv', $order);
oci_execute($stid);
if (isset($_POST['UpdateTR']))
{
$conn2 = oci_connect("XXX", "XX", "XX");
if (!$conn2)
{
$m = oci_error();
echo $m['message'], "\n";
exit;
}
$query2 = "UPDATE TABLE
SET SHIP_TO_STR_DLVR_STATUS='Y'
WHERE TRACKING_NUMBER = :updTR_bv";
$stid2 = oci_parse($conn2, $query2);
$updTR = $_POST['updTR'];
oci_bind_by_name($stid2, ':updTR_bv', $updTR);
oci_execute($stid2, OCI_COMMIT_ON_SUCCESS);
oci_free_statement($stid2);
oci_close($conn2);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="blurBg-false" style="background-color:#EBEBEB">
<!-- Start Formoid form-->
<link rel="stylesheet" href="form-solid-blue.css" type="text/css" />
<script type="text/javascript" src="jquery.min.js"></script>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
<div class="title">
<h2></h2>
<h2>Tracking & Receiving</h2>
</div>
<div class="element-input">
<label class="title"></label>
<div class="item-cont">
<input class="small" type="text" name="store" placeholder="Store #"/>
<span class="icon-place"></span>
</div>
</div>
<div class="element-input">
<label class="title"></label>
<div class="item-cont">
<input class="medium" type="text" name="userid" placeholder="UserId"/>
<span class="icon-place"></span>
</div>
</div>
<div class="element-input">
<label class="title"></label>
<div class="item-cont">
<input class="large" type="text" name="order" placeholder="Order Number"/>
<span class="icon-place"></span>
</div>
</div>
<div class="submit">
<input type="submit" name="Send" value="Send"/>
</div>
<div class="element-separator">
<hr>
<h3 class="section-break-title">Tracking Numbers</h3>
</div>
<div class="element-multiple">
<label class="title"></label>
<div class="item-cont">
<div class="large">
<?php
echo '<select data-no-selected="Nothing selected" name="updTR" multiple="no">';
while ($row = oci_fetch_array($stid, OCI_ASSOC))
{
$data[] = $row;
}
foreach ($data as $value)
{
//echo "<option value=\"option_1\">" . $value['TRACKING_NUMBER'] . "</option>";
echo "<option value="<?php $value['TRACKING_NUMBER']; ?>"><?php echo $value['TRACKING_NUMBER']; ?></option>";
//echo "selected = 'selected'";
}
echo '</select>';
oci_free_statement($stid);
oci_close($conn);
?>
<span class="icon-place"></span>
</div>
</div>
</div>
<div class="submit">
<input type="submit" name="UpdateTR" value="Submit"/>
</div>
</form>
<script type="text/javascript" src="formoid-solid-blue.js"></script>
</body>
</html>