function select_History_Date($link){
$status = '';
$sql = "SELECT Student_Id, Loaner_Laptop_Id, HDD_Id, "
. "Phone_Id, date_returned "
. "FROM equipment_history WHERE Loaner_Laptop_Id "
. "IS NOT NULL OR HDD_Id IS NOT NULL OR Phone_Id IS NOT NULL";
$ret = mysqli_query($link, $sql);
$row1 = mysqli_fetch_array($ret, MYSQLI_ASSOC);
if (!$ret) {
die('Could not execute select statement:' . mysqli_errno($link));
} else {
while ($row1 = mysqli_fetch_array($ret, MYSQLI_ASSOC)) {
$status .= '<tr>';
if(is_Null($row1)){
$status .= '<td><a href="ReturnLaptop.php?laptopId=' .
$row1['Loaner_Laptops_Id'] . 'studentId='.
$row1['Student_Id']. '">'. 'Return'. '</td>';
} else{
$status .= '<td>' . $row1['date_returned'] . '</td>';
}
}
$status .= '</tr>';
return $status;
}
}
我如何设想它应该是打印href链接,但它只是打印空白我错过了什么?或者这根本不可能做到。
答案 0 :(得分:0)
您正在检查$row1
是否为null
,但它永远不会是null
,因为您要在while
中进行分配。如果您在while
,那已经意味着它不是null
。
我敢打赌你错过了if(is_null($row1))
的索引,例如if(is_null($row1['value_to_check']))
。
答案 1 :(得分:0)
你来自db Loaner_Laptop_Id
$sql = "SELECT Student_Id, Loaner_Laptop_Id, HDD_Id, "
. "Phone_Id, date_returned "
. "FROM equipment_history WHERE Loaner_Laptop_Id "
. "IS NOT NULL OR HDD_Id IS NOT NULL OR Phone_Id IS NOT NULL";
使用$ row1 ['Loaner_Laptop s
_ Id']检查密钥:)