chat change view
This commit is contained in:
parent
47bd2689dd
commit
a28bb61c05
19
chat.php
19
chat.php
@ -17,15 +17,15 @@ $uid = $_SESSION['uid'];
|
||||
|
||||
if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
|
||||
|
||||
$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');
|
||||
|
||||
while ($message = $chat->fetch_assoc()) {
|
||||
$d = new DateTime($message['msgdate']);
|
||||
$m = htmlspecialchars($message['msg']);
|
||||
echo sprintf('%s [%s]: %s', $d->format('H:i'),$message['from'],$m)." <br>";
|
||||
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');
|
||||
while ($message = $chat->fetch_assoc()) {
|
||||
$d = new DateTime($message['msgdate']);
|
||||
$m = htmlspecialchars($message['msg']);
|
||||
echo sprintf('%s [%s]: %s', $d->format('H:i'),$message['from'],$m)." <br>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
@ -39,6 +39,9 @@ while ($message = $chat->fetch_assoc()) {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<?php show_messages(); ?>
|
||||
</div>
|
||||
<form action="chat.php" method="post">
|
||||
<input id="msg" name="msg" size="100" placeholder="Введите сообщение...">
|
||||
<input type="submit" value="Отправить">
|
||||
|
Loading…
Reference in New Issue
Block a user