ElaKiri Community
Downloads
(#1)
Old
gazaly's Avatar
gazaly gazaly is offline
Senior Member
gazaly has a spectacular aura aboutgazaly has a spectacular aura aboutgazaly has a spectacular aura about
 
Posts: 11,759
Join Date: Nov 2006
Location: S.A
Up Shoutbox - 06-28-2007, 01:03 AM

Making your own shoutbox at first might seem hard, but its simple and easy to make. Making a shoutbox can all be done with one file, specifically three steps, and you have to work backwards to have it function. First, you must make the submit action, which uploads the name and comments to the mySQL database. Secondly, you must have the display action which displays the comments. Finally, you need the form where the people can add the comments.
Before anything else though, you must make the mySQL database. I decided to add 4 fields to the database: id, name, message, and time. I called the table 'shoutbox' and the database 'news'. You can copy paste this code inside your mySQL database using a program such as PHPMyAdmin, or (type it in by hand if you feel so Here is the mySQL code I used:

CREATE TABLE `shoutbox` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`message` longtext NOT NULL,
`time` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;

The rest of the code from now down can all be placed on one single
page. Here's what we need to do for the first step, for the submit
action.

1. First off, connect to the database.
2. If submit is hit, then get the day and time to be stored on the database.
3. Insert the values of the id, name, comments, and time to the database.

Here it is in PHP:

//the host, name, and password for your mysql
mysql_connect("localhost","username","password");

//select the database
mysql_select_db("news");

if($submit)
{
//use the PHP date function for the time
$time=date("h:ia d/j/y");

// inserting it into the shoutbox table which we made in the mysql statements before
$result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)".
"VALUES ('NULL','$name', '$message','$time')");
}
?>

The second part of the Shoutbox is to display all the comments which other people have written. We can use a simple while loop to get all the rows from the mySQL Database:

1. Select the last five messages posted from the shourbox table.
2. Run the while loop while it keeps getting an row.
3. Define each variable from the database and echo it out.

Here it is in PHP:

//returning the last 5 messages
$result = mysql_query("select * from shoutbox order by id desc limit 5");

//the while loop
while($r=mysql_fetch_array($result))
{
//getting each variable from the table
$time=$r["time"];
$id=$r["id"];
$message=$r["message"];
$name=$r["name"];
?>


Finally, you have to write the form action for the shoutbox to load for
folks to post. Its not too hard, and sort of self explanatory:

Alright thats about it. You can see my code that I worked on: http://www.spoono.com/php/tutorials/...x/shoutbox.txt
In fact, the one for this tutorial is only 35 lines total. Make a new file and save it as shoutbox.php and put all of the code on this tutorial in the body.
Reply With Quote
(#2)
Old
shanX's Avatar
shanX shanX is offline
Senior Member
shanX is on a distinguished road
 
Posts: 9,944
Join Date: Oct 2006
Location: Kandy, LK
Send a message via MSN to shanX Send a message via Yahoo to shanX
06-28-2007, 11:30 AM

Quote:
Originally Posted by gazaly
Alright thats about it. You can see my code that I worked on: http://www.spoono.com/php/tutorials/...x/shoutbox.txt
Hmmmm....

Did u make this?? or try this?

Last edited by shanX; 06-28-2007 at 11:40 AM.
Reply With Quote
(#3)
Old
hemalsilva's Avatar
hemalsilva hemalsilva is offline
Senior Member
hemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to beholdhemalsilva is a splendid one to behold
 
Posts: 15,776
Join Date: Oct 2006
Location: Sri Lanka
Send a message via AIM to hemalsilva Send a message via Yahoo to hemalsilva Send a message via Skype™ to hemalsilva
06-28-2007, 11:34 AM

Reply With Quote
(#4)
Old
SaCh-101's Avatar
SaCh-101 SaCh-101 is offline
Senior Member
SaCh-101 is an unknown quantity at this point
 
Posts: 1,004
Join Date: Jan 2007
Location: sinharaja wanaantharaye mahaa galak yata
Send a message via MSN to SaCh-101 Send a message via Yahoo to SaCh-101
06-29-2007, 08:54 AM

thaanx macha lezzeee
Reply With Quote
(#5)
Old
SaCh-101's Avatar
SaCh-101 SaCh-101 is offline
Senior Member
SaCh-101 is an unknown quantity at this point
 
Posts: 1,004
Join Date: Jan 2007
Location: sinharaja wanaantharaye mahaa galak yata
Send a message via MSN to SaCh-101 Send a message via Yahoo to SaCh-101
06-29-2007, 08:59 AM

Quote:
Originally Posted by shanX
Hmmmm....

Did u make this?? or try this?

ehema ekak hadanna puluwannam mehema ideeyai ban
Reply With Quote
(#6)
Old
shanX's Avatar
shanX shanX is offline
Senior Member
shanX is on a distinguished road
 
Posts: 9,944
Join Date: Oct 2006
Location: Kandy, LK
Send a message via MSN to shanX Send a message via Yahoo to shanX
06-29-2007, 04:06 PM

Quote:
Originally Posted by SaCh-101
ehema ekak hadanna puluwannam mehema ideeyai ban


Hah hah, Owwath wedada???
Reply With Quote
(#7)
Old
fazaal24's Avatar
fazaal24 fazaal24 is offline
Senior Member
fazaal24 will become famous soon enoughfazaal24 will become famous soon enough
 
Posts: 33,028
Join Date: Nov 2006
Location: Carbon Canyon Dehiwala
Send a message via MSN to fazaal24
06-29-2007, 04:12 PM

hmm bit advanced..thx will try
Reply With Quote
(#8)
Old
Aphoo's Avatar
Aphoo Aphoo is offline
Senior Member
Aphoo is an unknown quantity at this point
 
Posts: 5,503
Join Date: Aug 2006
Location: @ home
Send a message via MSN to Aphoo
06-29-2007, 04:23 PM

thnxx
Reply With Quote
(#9)
Old
MCLINER's Avatar
MCLINER MCLINER is offline
Senior Member
MCLINER is on a distinguished road
 
Posts: 11,315
Join Date: Aug 2006
Location: UNDERGROUND
Send a message via MSN to MCLINER Send a message via Yahoo to MCLINER
06-29-2007, 04:39 PM

ayyo simple ne
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright © 2006 - 2011 ElaKiri™ Beta2.Evo vBulletin, vBa iBproArcade Subdreamer I-Magic MKv

Page generated in 0.05238 seconds with 9 queries