gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 15:01:43 24 4
gpt4 key购买 nike

我在将 PHP/MySQL 代码实现为 jgrowl 时遇到问题。

如果您熟悉 jgrowl,您就会知道它会像 Growl 在 OS X 上那样提供通知。

我试图让它读取我表中的所有记录,但目前它只显示一条记录作为通知,并且循环浏览 4 次。

另一个问题是,如果我的表中有 5 行,那么 jgrowl 将只显示 4 个将要查看的通知。

如何让它以通知形式查看表中的所有记录,以及如何以通知形式显示记录总数 (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>

最佳答案

你的问题绝对不在于获取行。
所有这些问题都源于同一个根源:目标不明确。您想要获得什么 JavaScript 代码?

你必须将你的工作分成两部分并分别完成:

  1. 除了 PHP 和 MySQL 之外,编写您的 Growl 或任何代码并对其进行调试,直到它开始工作。每一位数据都必须是硬编码的,就像根本没有PHP和mysql而你的数据是静态的一样。

  2. 一旦您开始使用 (1),最简单的部分就剩下了:只需编写 PHP/MySQL 代码即可生成 JavaScript 代码的精确副本。没什么大不了的。

仅此而已。
只是不要坐在两个凳子之间。
希望这有帮助

关于php - 从 MySQL 表中获取行并将其显示为 JGROWL 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2918032/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com