Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Find the min and max value before printing the table with same process. Then print in table.</p> <p>Process 1:</p> <pre><code>&lt;?php $i = 0; while ($i &lt; $num) { $cunit = mysql_result($result, $i, "costo_prod"); $incqta = mysql_result($result, $i, "incid_qta"); $inconf = ($cconf * $incqta / 100) + ($cunit * $incqta / 100); if ($cunit &gt; 0 &amp;&amp; $cunit &lt;= 0.2500) { $incprd = $cunit * 10 / 100; } elseif ($cunit &gt; 0.2500 &amp;&amp; $cunit &lt;= 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 &lt; $min_val) { $min_val = $przoff; } if ($przoff &gt; $max_val) { $max_val = $przoff; } } ?&gt; &lt;?php $i++; } $i = 0; while ($i &lt; $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 &gt; 0 &amp;&amp; $cunit &lt;= 0.2500) { $incprd = $cunit * 10 / 100; } elseif ($cunit &gt; 0.2500 &amp;&amp; $cunit &lt;= 0.5000) { $incprd = $cunit * 5 / 100; } else { $incprd = 0; } $przoff = ($cconf + $cunit + $inconf + $incprd); $min_val = $min_val; $max_val = $max_val; ?&gt; &lt;tr&gt; /* TABLE CONTENT */ &lt;/tr&gt; &lt;?php $i++; } ?&gt; </code></pre> <p>Process 2:</p> <pre><code>&lt;?php $min_val = ""; $max_val = ""; $i = 0; while ($i &lt; $num) { $cunit = mysql_result($result, $i, "costo_prod"); $incqta = mysql_result($result, $i, "incid_qta"); $inconf = ($cconf * $incqta / 100) + ($cunit * $incqta / 100); if ($cunit &gt; 0 &amp;&amp; $cunit &lt;= 0.2500) { $incprd = $cunit * 10 / 100; } elseif ($cunit &gt; 0.2500 &amp;&amp; $cunit &lt;= 0.5000) { $incprd = $cunit * 5 / 100; } else { $incprd = 0; } $przoff = ($cconf + $cunit + $inconf + $incprd); if ($przoff &lt; $min_val || empty($min_val)) { $min_val = $przoff; } if ($przoff &gt; $max_val || empty($max_val)) { $max_val = $przoff; } ?&gt; &lt;?php $i++; } $i = 0; while ($i &lt; $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 &gt; 0 &amp;&amp; $cunit &lt;= 0.2500) { $incprd = $cunit * 10 / 100; } elseif ($cunit &gt; 0.2500 &amp;&amp; $cunit &lt;= 0.5000) { $incprd = $cunit * 5 / 100; } else { $incprd = 0; } $przoff = ($cconf + $cunit + $inconf + $incprd); $min_val = $min_val; $max_val = $max_val; ?&gt; &lt;tr&gt; /* TABLE CONTENT */ &lt;/tr&gt; &lt;?php $i++; } ?&gt; </code></pre> <p>Only difference is min value and max value initializing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload