同じプロセスでテーブルを印刷する前に、最小値と最大値を見つけます。次に、表に印刷します。
プロセス1:
<?php
$i = 0;
while ($i < $num) {
$cunit = mysql_result($result, $i, "costo_prod");
$incqta = mysql_result($result, $i, "incid_qta");
$inconf = ($cconf * $incqta / 100) + ($cunit * $incqta / 100);
if ($cunit > 0 && $cunit <= 0.2500) {
$incprd = $cunit * 10 / 100;
} elseif ($cunit > 0.2500 && $cunit <= 0.5000) {
$incprd = $cunit * 5 / 100;
} else {
$incprd = 0;
}
$przoff = ($cconf + $cunit + $inconf + $incprd);
if ($i == 0) {
$min_val = $przoff;
$max_val = $przoff;
} else {
if ($przoff < $min_val) {
$min_val = $przoff;
}
if ($przoff > $max_val) {
$max_val = $przoff;
}
}
?>
<?php
$i++;
}
$i = 0;
while ($i < $num) {
$cod = mysql_result($result, $i, "cod_int");
$name = mysql_result($result, $i, "nome");
$conf = mysql_result($result, $i, "conf");
$type = mysql_result($result, $i, "tipo");
$cconf = mysql_result($result, $i, "cost");
$cunit = mysql_result($result, $i, "costo_prod");
$incqta = mysql_result($result, $i, "incid_qta");
$inconf = ($cconf * $incqta / 100) + ($cunit * $incqta / 100);
if ($cunit > 0 && $cunit <= 0.2500) {
$incprd = $cunit * 10 / 100;
} elseif ($cunit > 0.2500 && $cunit <= 0.5000) {
$incprd = $cunit * 5 / 100;
} else {
$incprd = 0;
}
$przoff = ($cconf + $cunit + $inconf + $incprd);
$min_val = $min_val;
$max_val = $max_val;
?>
<tr>
/* TABLE CONTENT */
</tr>
<?php
$i++;
}
?>
プロセス2:
<?php
$min_val = "";
$max_val = "";
$i = 0;
while ($i < $num) {
$cunit = mysql_result($result, $i, "costo_prod");
$incqta = mysql_result($result, $i, "incid_qta");
$inconf = ($cconf * $incqta / 100) + ($cunit * $incqta / 100);
if ($cunit > 0 && $cunit <= 0.2500) {
$incprd = $cunit * 10 / 100;
} elseif ($cunit > 0.2500 && $cunit <= 0.5000) {
$incprd = $cunit * 5 / 100;
} else {
$incprd = 0;
}
$przoff = ($cconf + $cunit + $inconf + $incprd);
if ($przoff < $min_val || empty($min_val)) {
$min_val = $przoff;
}
if ($przoff > $max_val || empty($max_val)) {
$max_val = $przoff;
}
?>
<?php
$i++;
}
$i = 0;
while ($i < $num) {
$cod = mysql_result($result, $i, "cod_int");
$name = mysql_result($result, $i, "nome");
$conf = mysql_result($result, $i, "conf");
$type = mysql_result($result, $i, "tipo");
$cconf = mysql_result($result, $i, "cost");
$cunit = mysql_result($result, $i, "costo_prod");
$incqta = mysql_result($result, $i, "incid_qta");
$inconf = ($cconf * $incqta / 100) + ($cunit * $incqta / 100);
if ($cunit > 0 && $cunit <= 0.2500) {
$incprd = $cunit * 10 / 100;
} elseif ($cunit > 0.2500 && $cunit <= 0.5000) {
$incprd = $cunit * 5 / 100;
} else {
$incprd = 0;
}
$przoff = ($cconf + $cunit + $inconf + $incprd);
$min_val = $min_val;
$max_val = $max_val;
?>
<tr>
/* TABLE CONTENT */
</tr>
<?php
$i++;
}
?>
唯一の違いは、最小値と最大値の初期化です。