โค้ด: เลือกทั้งหมด
$username = $user_show_all = $like_time = '';
while ($row = $this->db->sql_fetchrow($result)) {
$user_id[] = $row['user_id'];
$user_show[$row['user_id']] = $row['username'];
$like_time[$row['user_id']] = $row['like_time'];
}
กำหนด แบบ นี้หมายความว่า ตัวแปล $like_time เป็น string แล้ว line สุดท้ายมาบอกให้มันเป็น array ไม่ได้นะ หลายคนคิดว่ามันจะทับค่า บาง server ปรับให้แต่บาง server ไม่ปรับ และ มันเขียนผิดรูปแบบ
ควรเขียนอย่างนี้
โค้ด: เลือกทั้งหมด
// ....
$like_time = array();
while ($row = $this->db->sql_fetchrow($result)) {
$user_id[] = $row['user_id'];
$user_show[$row['user_id']] = $row['username'];
$like_time[$row['user_id']] = $row['like_time'];
}
โค้ด: เลือกทั้งหมด
$like_time = array();
while ($row = $this->db->sql_fetchrow($result)) {
$user_id = $row['user_id'];
$user_show[$user_id] = $row['username'];
$like_time[$user_id] = $row['like_time'];
}