![](/img/trans.png)
[英]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.