簡體   English   中英

用php進行mysql查詢的進度條

[英]progress bar with mysql query with php

我正在嘗試使用mysql查詢的迭代更新進度條,但我不明白如何更新進度條,以及如何找到已獲取的行數,例如:

$query = 'SELECT tvshows.genres, tvshows.id_show FROM tvshows where tvshows.genres is not NULL';
$result = mysql_query($query);

$num_rows = mysql_num_rows($result);
echo $num_rows;

這個: echo $num_rows; 是我獲取的行數,然后以這種方式迭代結果:

while ($db_row = mysql_fetch_assoc($result)) 
{
    //Do seomthing with the row

}

但是我怎么知道我要更新到哪一行然后更新進度欄? 誰知道一個很好的教程或示例代碼來制作進度條? 我發現了這個: http : //w3shaman.com/article/php-progress-bar-script

但是該示例需要以下條件:

 for($i=1; $i<=$total; $i++){
// Calculate the percentation
$percent = intval($i/$total * 100)."%";

而且我不知道如何用php查詢的結果來實現,任何人都可以幫助我?

如評論中所述,如果您必須使用進度條,那應該是一個非常慢的查詢。

如果是這樣,您可以在循環中添加一個簡單的計數器:

$i = 0;
while ($db_row = mysql_fetch_assoc($result)) 
{
    $i++;
    $percent = intval($i/$num_rows * 100)."%";

    //Do seomthing with the row

}

然后按照文章中所述進行操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM