$mysqli->query("SELECT b.t_follow_up, b.t_consultation, b.t_acid_peel, b.t_wrinkle_name, b.t_dermal_name, b.status, b.date_book, b.min_spent, b.b_ref, m.f_name, m.l_name, d.doctor_name, MIN(t.times)
FROM bookslot b
LEFT JOIN timeslot t ON b.id_timeslot = t.id_timeslot
LEFT JOIN member m ON b.id_member = m.id_member
LEFT JOIN doctor d ON b.id_doctor = d.id_doctor
while($r = $q->fetch_array(MYSQLI_ASSOC)) :
echo '. $r['t_consultation'] . ' ' . $r['t_follow_up'] . ' ' . $r['t_acid_peel'] . ' ' . $r['t_dermal_name'] . ' ' . $r['t_wrinkle_name'] ';
endwhile;WHILE循环结果:
i can put comma in while loop manually! the problem when there is no table treatment is empty, comma will still there
consultation follow_up acid peel dermal我听说我能用内爆。我该如何实现它?预期结果:
if echoing the treatments:
consultation, acid peel, wrinkle name, dermal name发布于 2011-02-23 21:57:42
您可以将所有值放入数组中,并删除空元素:
function isNotEmpty($element) {
return strlen($element) > 0;
}
while($r = $q->fetch_array(MYSQLI_ASSOC)) :
$arr = array($r['t_consultation'], $r['t_follow_up'], $r['t_acid_peel'], $r['t_dermal_name'], $r['t_wrinkle_name']);
echo implode(', ', array_filter($arr, 'isNotEmpty'));
endwhile;https://stackoverflow.com/questions/5091734
复制相似问题