【发布时间】:2021-05-19 00:49:53
【问题描述】:
我有一个问题,我将我的客户 ID 表左连接到我的免税表,当我在同一客户下有多个免税时,它只是提取与该客户关联的数据的第一个系统 ID,或者根本没有数据。我有 3 个提取相同的豁免,1 个除了客户姓名之外根本没有提取任何数据,其余的似乎还可以
这是列出所有要点击的客户的表单页面。对于没有特定用户 ID 的任何人,我都禁用了要单击的链接。
<table>
<tr>
<th>System ID</th>
<th>Customer</th>
<th>Fuel Type</th>
<th>Tax Type</th>
<th>Category</th>
<th>Expiration Date</th>
</tr>
<?php
$IDUser = $_SESSION['userid'];
$sql = "SELECT * FROM TaxExemption LEFT JOIN CustomerList ON TaxExemption.CustomerID = CustomerList.ID ORDER BY Customer, FuelType ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row['ID']."</td>";
$customerid = $row['CustomerID'];
$sql = "SELECT * FROM customerlist WHERE ID = '$customerid' ";
$result1 = $conn->query($sql);
if ($result1->num_rows > 0) {
while($row1 = $result1->fetch_assoc()) {
if($IDUser == '1' || $IDUser == '2' || $IDUser == '151' || $IDUser == '270') {echo "<td><a href='financefueltaxedit.php?ID=".$row['ID']."'>".$row1['Customer']."</a></td>"; }
else
{echo "<td>".$row1['Customer']."</td>";}
}}
echo "
<td>".$row['FuelType']."</td>
<td>".$row['TaxType']."</td>
<td>".$row['Category']."</td>
<td>".date_format(date_create($row['Expiration']),'m/d/Y')."</td></tr>
";
} }
else{echo "<tr><td style='text-align: center' colspan='5'>Currently No Exemptions Added</td></tr>";}
?>
</table>
</div>
这是提取信息的编辑页面 - 如果客户有多个豁免,则存在问题,因为他们都有不同的系统 ID,但客户编号相同
<div class="container">
<h2>Customer Exemption Detail</h2>
<ul>
<li style='background: #324b81; color:white' id='profile'>Profile</li>
</ul>
<br><br>
<p>Customer: <?php echo $row['Customer']?></p>
<form class='updatecustomer'>
<input name="ID" value="<?php echo $ID; ?>" hidden="hidden">
<table>
<tr>
<th>Customer ID:</th>
<td><input type="text" name='CustomerID' value="<?php echo $row['CustomerID']?>" readonly disabled></td>
</tr>
<tr>
<th>Name:</th>
<td><input type="text" name='name' value="<?php echo $row['Customer']?>" readonly disabled></td>
</tr>
<tr>
<th>FuelType:</th>
<td><input type="text" name='FuelType' value="<?php echo $row['FuelType']?>" readonly disabled></td>
</tr>
<tr>
<th>TaxType:</th>
<td><input type="text" name='TaxType' value="<?php echo $row['TaxType']?>" readonly disabled></td>
</tr>
<tr>
<th>Expiration:</th>
<td><input type="text" name='Expiration' value="<?php echo $row['Expiration']?>"></td>
</tr>
</table>
<br>
<input type="button" value="Update" id="update">
<input type="reset" value="Cancel" onclick="location.href='financefueltax.php';">
</form>
<?php }} ?>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#update').click(function(event){
event.preventDefault();
var data = $('.updatecustomer').serialize();
$.ajax ({
data:data,
url:'processor-financefueltaxedit.php',
type:'post'
});
function redirect(){
location.href='financefueltax.php';
}
setTimeout(redirect,500);
});
});
$(document).ready(function(){
var d = new Date();
var day = d.getDate();
var month = d.getMonth();
var year = d.getFullYear();
$('[name="statedate"], [name="feddate"], [name="Expiration"] ').datepicker({
dateFormat:'yy-mm-dd',
minDate: new Date(year - 1, month, day - 7),
maxDate: new Date(year + 2, month, day)
});
});
</script>
</body>
这是我的处理器页面 - 允许单一豁免客户正确显示 - 我只希望能够更改日期并将新的到期日期发布到 taxexemptions 表,我不希望编辑其他信息因此只读字段- 这就是为什么我只有一个日期的更新声明。
<?php
require 'wconnectionfile.php';
$date = $_POST['date'];
$date = date_create($date);
$date = date_format($date, "Y-m-d");
$CustomerID = $_POST['CustomerID'];
$fueltype = $_POST['fueltype'];
$taxtype = $_POST['taxtype'];
$statetax = $_POST['statetax'];
$fedtax = $_POST['fedtax'];
if (!empty($date)) {
if (!empty($fedtax)) {$taxtype = $fedtax; } else {$taxtype = $statetax;}
$sql = "UPDATE taxexemption LEFT JOIN CustomerList ON TaxExemption.CustomerID = CustomerList.ID SET taxexemption.Expiration='$date' WHERE taxexemption.CustomerID='$CustomerID'";
if ($conn->query($sql) === TRUE) {
}
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
对于多重豁免我不知道该怎么做,更不用说它没有将更新的日期从日期选择器发布到数据库
【问题讨论】:
标签: javascript php html jquery mysql