Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果数量增加,则必须使用php增加进度条_Php - Fatal编程技术网

如果数量增加,则必须使用php增加进度条

如果数量增加,则必须使用php增加进度条,php,Php,我需要完全像下面的网址下的购买它的按钮 URL: 当购买数量增加时,进度条将逐步移动 我需要准确地实现这个功能 请参考我的任何想法或样本代码 提前感谢如果你真的需要准确,你很可能需要在客户端绘制。PHP脚本可以返回一个描述进度条位置的JSON对象,然后脚本将其绘制出来。下面是来自SO的另一个问题,列出了一些JavaScript图形选项:PHP $purchased_num = 13; // items purchased until now (example) $max_width = 400

我需要完全像下面的网址下的购买它的按钮

URL

当购买数量增加时,进度条将逐步移动

我需要准确地实现这个功能

请参考我的任何想法或样本代码


提前感谢

如果你真的需要准确,你很可能需要在客户端绘制。PHP脚本可以返回一个描述进度条位置的JSON对象,然后脚本将其绘制出来。下面是来自SO的另一个问题,列出了一些JavaScript图形选项:

PHP

$purchased_num = 13; // items purchased until now (example)

$max_width = 400; // the width of the bar
$max_pur   = 50;  // the maximum number of items
$one_pur_width = round( $max_width / $max_pur );

$width = $one_pur_width * $purchased_num;

// print the div with this width
// and style the bar with css
// ...

您应该使用jQuery频繁地重新加载这个小部分

<div id="progBar">
</div>

<script type=text/javascript>
function refreshProgress() {
    $.get('/folder/progbar.php', function (data) {
       $('#progBar').html(data);
    }
    setTimeout('refreshProgress();',10000);
}

$(function () { refreshProgress(); });
</script>

函数刷新进度(){
$.get('/folder/progbar.php',函数(数据){
$('#progBar').html(数据);
}
setTimeout('refreshProgress();',10000);
}
$(函数(){refreshProgress();});

当页面加载到div中(该页面将根据当时的销售额生成当前进度条)时,这将加载progbar.php,并每10秒刷新一次。

您确定php是用于此操作的正确工具吗?