仅限php和mysql的shoutbox
我正在尝试只使用php和mysql构建shoutbox 我使用的代码如下:仅限php和mysql的shoutbox,php,mysql,sql,Php,Mysql,Sql,我正在尝试只使用php和mysql构建shoutbox 我使用的代码如下: <?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
<?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>
我知道网上有很多jqueryshoutbox可用,但我对jquery一无所知。所以把我的问题贴在这里
问题:
1:我希望在用户按submit后立即显示输出。他的喊声也应该出现在表格中,而不会刷新页面
2:我希望输出以滚动的方式显示,就像正常的shoutbox一样。
有人慷慨地帮助我编写这个小脚本。。。。。。不刷新页面。。。。那么你需要ajax来处理这个问题。@jean gkol,你能修改这个代码来使用ajax吗,@junaid不是一个免费的代码编写服务。问一个具体的问题。