duaj39673 2015-02-20 02:50
浏览 19

php和mysql只有shoutbox

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?