以下函数将行计数显示为4,但其仅打印一行。任何人都可以帮我解决错误
function list_appointments_table() {
global $db;
$start_date = date('Y-m-d');
$end_date = date('Y-m-d', strtotime('+15 days'));
$query = "SELECT * FROM lead_details WHERE next_meet between '".$start_date."' AND '".$end_date."'";
$result = $db->query($query) or die($db->error);
echo $result->num_rows;
$content = "";
$i=1;
while($lead_detail_row = $result->fetch_array()) {
$query = "SELECT * FROM leads WHERE lead_id='".$lead_detail_row['lead_id']."'";
$result = $db->query($query) or die($db->error);
$lead_row = $result->fetch_array();
$content .= '<tr><td>'.$i.'</td><td>';
$content .= $lead_row['business_name'];
$content .= '</td><td>';
$content .= $lead_row['phone_number'];
$content .= '</td><td>';
$content .= FormatDateOutput($lead_detail_row['next_meet']);
$content .= '</td></tr>';
$i++;
}
echo $content;
}
答案 0 :(得分:0)
function list_appointments_table() {
global $db;
$start_date = date('Y-m-d');
$end_date = date('Y-m-d', strtotime('+15 days'));
$query = "SELECT * FROM lead_details WHERE next_meet between '".$start_date."' AND '".$end_date."'";
$result = $db->query($query) or die($db->error);
echo $result->num_rows;
$content = "";
$i=1;
while($lead_detail_row = $result->fetch_array()) {
$query = "SELECT * FROM leads WHERE lead_id='".$lead_detail_row['lead_id']."'";
$result2 = $db->query($query) or die($db->error);
$lead_row = $result2->fetch_array();
$content .= '<tr><td>'.$i.'</td><td>';
$content .= $lead_row['business_name'];
$content .= '</td><td>';
$content .= $lead_row['phone_number'];
$content .= '</td><td>';
$content .= FormatDateOutput($lead_detail_row['next_meet']);
$content .= '</td></tr>';
$i++;
}
echo $content;
}
请修改以上代码。注意循环中变量名称的变化。