controleren of bericht al gepost is
lex van der poel
06/06/2012 14:36:28Hoi,
Ik heb een chat die om de twee seconden dit bestand laad:
Nu heb ik een manier nodig om te zorgen dat die alleen de berichten van max 3 seconden geleden post kan iemand mij hierbij helpen?
Toevoeging op 06/06/2012 14:37:51:
Dit is trouwens de output:
Misschien is het dan makkelijker te snappen :P
Ik heb een chat die om de twee seconden dit bestand laad:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
session_start();
require_once('config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Unable to connect to server, Please contact the site administrator');
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database, Please contact the site administrator");
}
$result = mysql_query('SELECT a.date, a.msg, b.username FROM chat a, users b WHERE a.posterid = b.ID ORDER BY a.ID DESC LIMIT 10');
if (!$result) {
die('Could not query:' . mysql_error());
}
while ($row = mysql_fetch_array($result)) {
$time = explode(" ", $row["date"]);
$array = $array . "[" . $time[1] . "] [" . $row["username"] . "] [Web-Chat]: " . $row["msg"] . "<br />";
}
$array = array("message"=>$array);
echo json_encode($array);
mysql_close($link);
?>
session_start();
require_once('config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Unable to connect to server, Please contact the site administrator');
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database, Please contact the site administrator");
}
$result = mysql_query('SELECT a.date, a.msg, b.username FROM chat a, users b WHERE a.posterid = b.ID ORDER BY a.ID DESC LIMIT 10');
if (!$result) {
die('Could not query:' . mysql_error());
}
while ($row = mysql_fetch_array($result)) {
$time = explode(" ", $row["date"]);
$array = $array . "[" . $time[1] . "] [" . $row["username"] . "] [Web-Chat]: " . $row["msg"] . "<br />";
}
$array = array("message"=>$array);
echo json_encode($array);
mysql_close($link);
?>
Nu heb ik een manier nodig om te zorgen dat die alleen de berichten van max 3 seconden geleden post kan iemand mij hierbij helpen?
Toevoeging op 06/06/2012 14:37:51:
Dit is trouwens de output:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
{"message":"[13:26:52] [DogMan] [Web-Chat]: hsfghf
[20:14:20] [DogMan] [Web-Chat]: lol
[19:52:52] [DogMan] [Web-Chat]: lol
[19:52:43] [DogMan] [Web-Chat]: lol
[19:52:10] [DogMan] [Web-Chat]: test
[19:51:43] [DogMan] [Web-Chat]: lol
[19:46:39] [DogMan] [Web-Chat]: test
[17:28:38] [DogMan] [Web-Chat]: hoi
[17:22:18] [DogMan] [Web-Chat]:
[17:07:25] [DogMan] [Web-Chat]: lol
"}
[20:14:20] [DogMan] [Web-Chat]: lol
[19:52:52] [DogMan] [Web-Chat]: lol
[19:52:43] [DogMan] [Web-Chat]: lol
[19:52:10] [DogMan] [Web-Chat]: test
[19:51:43] [DogMan] [Web-Chat]: lol
[19:46:39] [DogMan] [Web-Chat]: test
[17:28:38] [DogMan] [Web-Chat]: hoi
[17:22:18] [DogMan] [Web-Chat]:
[17:07:25] [DogMan] [Web-Chat]: lol
"}
Misschien is het dan makkelijker te snappen :P
Gewijzigd op 06/06/2012 14:39:47 door Lex van der poel
Er zijn nog geen reacties op dit bericht.