-2
我試圖根據所選員工的值提取相關津貼價格。當我選擇一個員工時,會生成津貼類型,但是對於每種津貼類型,回報相同的價格。根據下拉框選擇生成的值填充文本字段
我嘗試下面的代碼,但找不到錯誤。你能幫我找到我的代碼中的錯誤?
<div class="form-group">
<label class="control-label col-lg-4" for="advanceAmount">Allowances: </label>
<div class="col-lg-3">
<?php
for($i = 0; $i < count($b); $i++){
echo '<input type="text" class="form-control input-sm margin-bottom" name="allowance_type" value="' . $b[$i] . '">';
}
?>
</div>
<div class="col-lg-3">
<?php
$i = 0;
$s = mysqli_query($connection,"select * from allowances_payroll where allowance_name = '$b[$i]'");
$r = mysqli_fetch_assoc($s);
for($i = 0; $i < count($b); $i++){
echo '<input type="text" class="form-control input-sm margin-bottom" value="' . $r['allowance_amount'] . '">';
}
?>
</div>
</div>
$ b是展開數據庫中的許可類型。
if($result1){
while($record = mysqli_fetch_array($result1)){
$empId = $record['emp_id'];
$department = $record['dep_name'];
$salary = $record['emp_basicSalary'];
$designation = $record['emp_classification'];
$allowance = $record['allowances_types'];
$b = explode(" ,", $allowance);
}
}
感謝
非常感謝。它按預期工作。 – lakshi