如何使用 mysql implode while 循环
$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
$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 LOOP RESULT:
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
i heard i can use implode. how do i implement it? EXPECTED RESULT:
if echoing the treatments:
consultation, acid peel, wrinkle name, dermal name
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将所有值放入数组中并删除空元素:
You can put all values in an array and remove empty elements: