所以我正在编辑一个公司创建但从未完成的网站,我的价格计算器有问题。
基本上,它将从a到b的每个值相加。我需要它来添加没有起始值的所有内容。我会粘贴一些代码进行澄清。
该脚本的基本作用是将所选范围内的每个单个值相加。我需要它来求和而不需要用户选择的起始值。
$rank[4][5] = 4;
$rank[4][4] = 5;
$rank[4][3] = 6;
$rank[4][2] = 7;
$rank[4][1] = 8;
$rank[5][5] = 9;
$rank[5][4] = 11;
$rank[5][3] = 13;
$rank[5][2] = 15;
$rank[5][1] = 16;
$rank[6][1] = 19;
$rank[7][1] = 20;
if($ce == 'rankval1')
$starting = 1;
else if($ce == 'rankval2')
$starting = 2;
else if($ce == 'rankval3')
$starting = 3;
else if($ce == 'rankval4')
$starting = 4;
else if($ce == 'rankval5')
$starting = 5;
else if($ce == 'rankval6')
$starting = 6;
if($de == 'rankval1')
$end = 1;
else if($de == 'rankval2')
$end = 2;
else if($de == 'rankval3')
$end = 3;
else if($de == 'rankval4')
$end = 4;
else if($de == 'rankval5')
$end = 5;
else if($de == 'rankval6')
$end = 6;
else if($de == 'rankval7')
$end = 7;
$this->price = 0;
//$starting = 1;
//$end = 3;
for($i=$starting; $i<=$end; $i++) {
if($i == 6 || $i == 7) {
if($starting != $i)
$this->price += $rank[$i][1];
}
else
if($starting == $end) {
for($j=$starting_points; $j>=$end_points; $j--) {
$this->price += $rank[$i][$j];
}
}
else if($i==$starting) {
for($j=$starting_points; $j>=1; $j--) {
$this->price += $rank[$i][$j];
}
}
else if($i==$end) {
for($j=$end_points; $j<=5; $j++) {
$this->price += $rank[$i][$j];
}
}
else {
for($j=5; $j>=1; $j--) {
$this->price += $rank[$i][$j];
}
}
}