I am trying to build shoutbox using php and mysql only.
I am using the code below:
<?php
$sqldisplay =$Db1->query("select * from shoutbox ORDER BY date_time DESC");
?>
<h4>shout box input here</h4>
<form method="post" action="">
Message: <input type="text" id="message" name="message" class="message" />
<input type="submit" id="submit" value="Submit" name="shout" />
</form>
<?php
if(isset($_REQUEST['shout']))
{
$message = htmlspecialchars(mysql_real_escape_string($_POST['message']));
$sqlact =$Db1->query("Insert into shoutbox Values(NULL,NOW(),
'$username','$message')");
echo "save db";
}
?>
<table>
<thead><tr><td colspan="3">
<center>shout box output here</center></td></tr><tr><th>date</center></th>
<th><center>username</center></th>
<th><center>message</center></th></tr></thead>
<?php
while($row = mysql_fetch_array($sqldisplay))
{
echo "<tr> ";
echo "<td>" .$row[date_time] . "</td>";
echo "<td>" .$row[name] . "</td>";
echo "<td>" .$row[message] . "</td>";
}
echo "</tr> ";
?>
</table>
I know there are lots of jquery shoutbox available on net, but i have no idea about jquery. so posting my question here.
Problems:
1: I want the output to be displayed right after user press submit. his shout should also appear in the table with out refreshing the page
2:I want the output to displayed in scrolling manner as does the normal shoutbox shoul look like.e.g.
http://skrypty.klocus.pl/2012/01/php-ajax-shoutbox.html
Someone generous enough to help me in building this little script.