Home arrow PHP arrow Page 3 - Chatter

View Chatter - PHP

This tutorial shows you how to make a ChatterBlock. ChatterBlocks are small windows where users can type in messages. They're also called Shout Boxes or TagBoards and are kind of like miniature chat rooms.

TABLE OF CONTENTS:
  1. Chatter
  2. Configuration
  3. View Chatter
  4. Manage the Chatter
  5. Secure it
By: Roger Stringer
Rating: starstarstarstarstar / 29
November 08, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The iframe in chatter.html will load this 'View Chatters' page. You can format this page to look how you want the chatterblock to be displayed. Let's take a look at the code.

<body onload=window.setTimeout("location.href='view.php'",120000)>
<?php
include('chatter.php');
$q = "select * from chatterblock order by id desc ";
$result = mysql_query($q);
while ($row = mysql_fetch_array($result)) {
$id = $row["id"];
$name=$row["name"];
$url = $row["url"];
$msg = $row["msg"];
echo "<b><a href=\"$url\" target=\"new\">$name</a></b>: $msg<hr>";
}
?>

Basically code selects all the entries in the chatterblock to be listed, in the order of oldest last, newest first (chronological order). I only put in some basic format to display the entries; you can insert CSS, tables or whatever you like inside this part. In the above code, a user's name is displayed in bold with a hyperlink to the url entered.

Note: It'll display the hyperlink regardless of whether a url is entered or not. if you want it to be more intelligent, run a simple if check to see if $url has a value. If $url is empty, then don't display the hyperlink.

The message is displayed at the side of the name. Each entry is separated by a horizontal rule.

Save this file as view.php



 
 
>>> More PHP Articles          >>> More By Roger Stringer
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap

Dev Shed Tutorial Topics: