我希望按日期过滤结果,我开始工作得很好。现在,我尝试让数据库根据过滤期间的每个员工返回值。员工表中的示例:
ID Hourly
然后在数据表中
ID Hours
所以我一直在尝试,如果ID匹配,那么查看每小时和小时的总和。这就是我到目前为止所拥有的。
<?php
$con=mysqli_connect("MY_INFO.com","USER","*********","DB_NAME");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$data = mysqli_query($con,"Select * FROM employees
Select * FROM data
SELECT t1 *, t2.*
From employees t1
INNER JOIN data t2 on t1.id = t2.id
'");
while($data = mysqli_fetch_array($data)) {
echo $data['id'] . " " . $data['id'];
echo "<br>";
}
$result = mysqli_query($con,"SELECT * FROM friends
WHERE date >'2014-09-1' and date < '2014-9-30'");
while($row = mysqli_fetch_array($result)) {
echo $row['name'] . " " . $row['id'];
echo "<br>";
我试图按日期过滤,然后匹配两个表中的ID,这样如果id等于另一个表中的id,那么它可以返回小时工资。因此,如果员工身份:1的小时工资为20美元/小时,工作2小时,那么我可以让它返回40美元。表格中包含:
Employee:
ID $/hr
1 20
Data:
ID Hours
1 2