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.

  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



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)>
$q = "select * from chatterblock order by id desc ";
$result = mysql_query($q);
while ($row = mysql_fetch_array($result)) {
$id = $row["id"];
$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
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates


Dev Shed Tutorial Topics: