Reputation: 60731
i am still deciding on the database schema, but i will have chats saved in a database table. the mysql db will constantly be updated. what would be the friendliest way to display the data from the database? should i just use php to do it? is there something easier? can soemone give me examples of code of how to display the data in a friendly, good-looking way
Upvotes: 0
Views: 83
Reputation: 6992
Assuming you're using PHP and MySQL and have a MySQLi connection in variable $mysqli; Database structure would look like this:
id int(7) - primary key with autoincrement , author varchar(255), timestamp timestamp (sql type), content text(0)
php code would be:
<?php
$q = $mysqli->query('SELECT id, author, UNIX_TIMESTAMP(timestamp) AS time, content FROM table';
while($row = $q->fetch_object())
echo date('l jS \of F Y h:i:s A', $row->time).'<b> <'.$row->author.'></b>: '.$row->content.'<br />;
?>
This example would output something like Sunday 2nd of January 2010 09:31:02 PM <Cypher>: Hello, dude!
Upvotes: 1