[英]MYSQL PHP API - Displaying & Fetching multiple rows within rows from another table
[英]Fetching rows from MySQL table and displaying them as JGROWL notifications
我在将我的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代码?
您必须将工作分为两部分并分别完成:
除了PHP和MySQL,还可以编写Growl或任何代码,然后对其进行调试,直到它起作用为止。 数据的每一位都必须经过硬编码,就像根本没有PHP和mysql一样,您的数据是静态的。
一旦您开始工作(1),最简单的部分将仍然存在:只需编写一个PHP / MySQL代码即可生成您的JavaScript代码的精确副本 。 没有大碍。
就这样。
只是不要坐在两个凳子之间。
希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.