Javascript 通过每个ID具有多个数据的左连接拉取数据
我有一个问题,我将我的客户ID表加入我的免税表,当我在同一客户下有多个免税时,它只提取与该客户关联的数据的第一个系统ID,或者根本没有数据。我有3个拉相同的豁免,1个拉没有任何数据,除了客户的名字,其余的似乎还好 这是列出所有要单击的客户的表单页面。对于没有特定用户ID的任何人,我已禁用要单击的链接Javascript 通过每个ID具有多个数据的左连接拉取数据,javascript,php,html,jquery,mysql,Javascript,Php,Html,Jquery,Mysql,我有一个问题,我将我的客户ID表加入我的免税表,当我在同一客户下有多个免税时,它只提取与该客户关联的数据的第一个系统ID,或者根本没有数据。我有3个拉相同的豁免,1个拉没有任何数据,除了客户的名字,其余的似乎还好 这是列出所有要单击的客户的表单页面。对于没有特定用户ID的任何人,我已禁用要单击的链接 <table> <tr> <th>System ID</th> <th>Customer&
<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
顾客
燃料类型
税种
类别
到期日期
对于多重豁免问题,由您或您的客户决定如何处理;您可以:
- 允许每个客户端有多个免税,并立即创建一个编辑页面,用于编辑相对于客户端的免税
- 不允许多个免税,为此,您必须删除每个客户重复的免税
选项A不会让我处于同一条船上,我仍然需要找出如何将不同的关联系统id拉入单个客户端页面,如果我可以在那里执行,我可以在豁免列表视图中执行?我喜欢将客户机下的所有免税项作为一个页面列出的想法,但他们想很容易地看到哪些免税项即将到期,这就是为什么他们的巨大列表视图。对于选项a,客户机页面将包含一个所有免税项的表(即系统id)我最终将taxexemptions的主键字段改为ExcemptionID,因为我的问题是将行结果显示为$row['ID';两个表都有一个名为ID的字段,因此它将提取customerlist ID而不是taxexemption ID;通过将Taxemption ID更改为Exception ID,我可以使onclick使用“Exception ID”而不是“ID”,后者通过JOIN不断拉取customerlist。-仍然在搞乱这个,但我把它正确地显示出来了。。。现在尝试发布数据
<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>
<?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();
?>