dotj6816 2010-05-27 02:03
浏览 40
已采纳

从MySQL表中获取行并将其显示为JGROWL通知

I am having problems implementing my PHP/MySQL code into a jgrowl.

If you are familiar with jgrowl you will know it delivers notifications like Growl does for OS X.

I am trying to get it read all the records from my table but at the moment it is only displaying one record as a notification and it loops through it 4 times.

Another problem is that if I have 5 rows in the table then jgrowl will only display 4 notifications are going to be viewed.

How do I get it to view all the records in the table as notifications and how do I display the total number of records (5) as notifications and account for the missing one at the moment?

        <script type="text/javascript"> 

        // In case you don't have firebug...
        if (!window.console || !console.firebug) {
            var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
            window.console = {};
            for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
        }

        (function($){

            $(document).ready(function(){

                // This specifies how many messages can be pooled out at any given time.
                // If there are more notifications raised then the pool, the others are
                // placed into queue and rendered after the other have disapeared.
                $.jGrowl.defaults.pool = 5;

                var i = 1;
                var y = 1;

                setInterval( function() {
                    if ( i < <?php echo $totalRows_comment; ?> ) {

                    <?php

                    echo '$.jGrowl("'.$row_comment['comment'].'",';

                                 ?>

                                 {
                            sticky:         true,
                            log:            function() {
                                console.log("Creating message " + i + "...");
                            },
                            beforeOpen:     function() {
                                console.log("Rendering message " + y + "...");
                                y++;
                            }
                        });
                    }

                    i++;
                } , 1000 );

            });
        })(jQuery);

        </script>                     
                    <p>

</span>
<p>
  • 写回答

1条回答 默认 最新

  • dongpu3792 2010-05-27 02:14
    关注

    Your problem is definitely not in fetching rows.
    All these problems grows from the same root: an unclear goal. What javascript code you want to get?

    You have to divide your job into 2 parts and done them separately:

    1. Apart from PHP and MySQL write your Growl or whatever code and and debug it until it gets to work. Every bit of data must be hardcoded, just like there is no PHP and mysql at all and your data is static.

    2. Once you get (1) to work, the easiest part will remain: just write a PHP/MySQL code that generates exact copy of your javascript code. Not a big deal.

    That's all.
    Just don't sit between 2 stools.
    Hope this helps

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口