简体   繁体   English

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

[英]Fetching rows from MySQL table and displaying them as JGROWL notifications

I am having problems implementing my PHP/MySQL code into a jgrowl. 我在将我的PHP / MySQL代码实现到jgrowl中时遇到问题。

If you are familiar with jgrowl you will know it delivers notifications like Growl does for OS X. 如果您熟悉jgrowl,您将知道它会像Growl一样为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. 我试图让它从我的表中读取所有记录,但目前它仅显示一条记录作为通知,并且它遍历4次。

Another problem is that if I have 5 rows in the table then jgrowl will only display 4 notifications are going to be viewed. 另一个问题是,如果我在表中有5行,那么jgrowl将仅显示4条要查看的通知。

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? 如何获取它以通知的形式查看表中的所有记录,以及如何以通知的形式显示记录总数(5)并说明当前缺少的记录?

        <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>

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? 您想获得什么JavaScript代码?

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. 除了PHP和MySQL,还可以编写Growl或任何代码,然后对其进行调试,直到它起作用为止。 Every bit of data must be hardcoded, just like there is no PHP and mysql at all and your data is static. 数据的每一位都必须经过硬编码,就像根本没有PHP和mysql一样,您的数据是静态的。

  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. 一旦您开始工作(1),最简单的部分将仍然存在:只需编写一个PHP / MySQL代码即可生成您的JavaScript代码的精确副本 Not a big deal. 没有大碍。

That's all. 就这样。
Just don't sit between 2 stools. 只是不要坐在两个凳子之间。
Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MYSQL PHP API-在另一个表的行中显示和获取多行 - MYSQL PHP API - Displaying & Fetching multiple rows within rows from another table 从多个用户获取行并按日期顺序显示它们 - fetching rows from multiple users and displaying them ordered by date 从mysql表中获取多个关联的行 - Fetching mutiple associated rows from mysql table 从表中获取多行并将其添加到另一个表中,然后使用复选框从上一个表中删除 - Fetching Multiple Rows from Table and Adding Them into Another Table and then Remove from Previous Table, Using Checkboxes 在wordpress中禁用jgrowl通知 - Disable jgrowl notifications in wordpress 从MySQL获取随机行并使用PHP显示它 - Fetching a random row from MySQL and displaying it with PHP 查询mysql表中具有相同月份值的行,并存储为php数组,以备后用在日历上显示它们 - query a mysql table for rows that have the same month value and store as a php array for later use displaying them on a calendar 从mysql表中获取最近30天的数据并按日期分组 - Fetching last 30 days data from mysql table and grouping them by date 将mysql条目加在一起并在表中显示它们 - Adding mysql entries together and displaying them in a table 使用 PHP 和 jQuery 从 MySQL 获取数据并显示在与用户 ID 匹配的 HTML 表中 - Fetching Data from MySQL using PHP & jQuery and displaying in HTML table matching the user ID
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM