我正在尝试通过 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;
this: 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
}
然后按照文章中提到的去做。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)