System chat from zayavka

This commit is contained in:
lopar
2018-11-05 22:54:18 +02:00
parent 073d56fc6b
commit 9d14ff16b3
3 changed files with 24 additions and 15 deletions
+15 -5
View File
@@ -18,10 +18,20 @@ if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?
function show_messages()
{
$chat = db::c()->query('SELECT `msg`, `msgdate`, (SELECT `login` FROM `users` WHERE `users`.`id` = `uid`) AS `from` FROM `chat` ORDER BY `id` ASC LIMIT 50');
$chat = db::c()->query('
SELECT
`msg`,
`msgdate`,
(SELECT `login` FROM `users` WHERE `users`.`id` = `uid`) AS `from`,
`type`
FROM `chat` ORDER BY `id` ASC LIMIT 50');
while ($message = $chat->fetch_assoc()) {
$d = new DateTime($message['msgdate']);
$m = htmlspecialchars($message['msg']);
if (!empty($message['type'])) {
echo sprintf('<span style="color:maroon">%s %s</span>', $d->format('H:i'),$m)." <br>";
}
echo sprintf('%s [%s]: %s', $d->format('H:i'),$message['from'],$m)." <br>";
}
}
@@ -42,8 +52,8 @@ show_messages();
<!--<div>-->
<?php ?>
<!--</div>-->
<!--<!--<form action="chat.php" method="post">-->-->
<!--<!-- <input id="msg" name="msg" size="100" placeholder="Введите сообщение...">-->-->
<!--<!-- <input type="submit" value="Отправить">-->-->
<!--<!--</form>-->-->
<!--<form action="chat.php" method="post">-->
<!-- <input id="msg" name="msg" size="100" placeholder="Введите сообщение...">-->
<!-- <input type="submit" value="Отправить">-->
<!--</form>-->
<!--</body>-->