prepare("UPDATE users SET tagline=?, location=? WHERE id=?") ->execute([$tag, $loc, $id]); $u['tagline'] = $tag; $u['location'] = $loc; $msg = 'Profile saved.'; } } $d = db(); $s = $d->prepare("SELECT COUNT(*) FROM posts WHERE user_id=?"); $s->execute([$id]); $posts = (int)$s->fetchColumn(); $s = $d->prepare("SELECT game, MAX(score) sc FROM scores WHERE user_id=? GROUP BY game"); $s->execute([$id]); $best = $s->fetchAll(); page_start('Profile: ' . $u['username'], ['back' => '/index.php']); if ($msg) p_ok($msg); p_para('User: ' . $u['username'] . ($u['is_admin'] ? ' [admin]' : '')); if ($u['tagline'] !== '') p_para('"' . $u['tagline'] . '"'); if ($u['location'] !== '') p_para('From: ' . $u['location']); p_para('Joined: ' . date('d/m/Y', (int)$u['created_at'])); p_para('Last seen: ' . ($u['last_seen'] ? ago((int)$u['last_seen']) . ' ago' : 'never')); p_para('Forum posts: ' . $posts); foreach ($best as $b) p_para('Best ' . $b['game'] . ': ' . $b['sc']); p_rule(); if ($mine) { p_para('Edit your details:'); p_form('/profile.php', [ ['name' => 'tagline', 'label' => 'Tagline', 'value' => $u['tagline'], 'maxlength' => 80], ['name' => 'location', 'label' => 'Location', 'value' => $u['location'], 'maxlength' => 40], ], 'Save'); p_links([['/password.php', 'Change password'], ['/inbox.php', 'My inbox']]); } elseif ($me) { p_links([['/compose.php', 'Send message', ['to' => $u['id']]]]); } p_links([['/users.php', 'Member list'], ['/index.php', 'Home']]); page_end();