好的,我们开始吧..
假设$topic['is_new']
由“7325823”组成,accID 是 63426,然后它会更新为 7325823|63426 但如果我再次重新加载页面,它会删除 7325823| 所以它只有 63426。我不想要那个。
怎么了?想不通
$accID = userid goes here;
$topic['is_new'] = "72482|81249|8124|42534|...and so on"; // user ids that i get from field in topics table
$list_of_ids = explode('|', $topic['is_new']);
// lets see if the user has already been here
if (!in_array($accID, $list_of_ids)) {
$in = isset($topic['is_new']) && !in_array($accID, $list_of_ids) ? $topic['is_new'].'|'.$accID : $topic['is_new'].'|'.$accID;
} else {
// if he havent, add him to the list
$in = $accID;
}
// yes i know, PDO is better
mysqli_query("UPDATE topics
SET num_views = num_views+1, is_new = '$in'
WHERE id = $tid") or die(mysqli_error($link));
这就是我想要实现的:自定义 php 论坛 - 显示新的/未读的帖子