我有员工信息表和员工贷款表.. 我使用这个查询:
$result=mysqli_query($con,"select tblemployeeinfo.employeeid, tblemployeeloan.amount from tblemployeeinfo left join tblemployeeloan on tblemployeeinfo.employeeid = tblemployeeloan.employeeid where tblemployeeinfo.employeeid = <employee id for example employee id 1>");
while($row = mysqli_fetch_array($result)){
echo "<br>".$row['employeeid'];
echo "<br>".$row['amount'];
}
结果是
employee id: 1
amount: 1000
employee id: 1
amount: 500
employee id: 1
amount: 100
但我想要的是这样显示:
employee id: 1
amount: 1000
amount: 500
amount: 100
抱歉我的英语不好。提前交易
最佳答案
普通的黑客可以通过下面的代码完成
$i = 0 ;
while($row = mysqli_fetch_array($result)){
if($i == 0)
echo "<br>".$row['employeeid'];
echo "<br>".$row['amount'];
$i++;
}
关于php mysql : joining two tables,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43292277/