Re: comparison problem
| From: | Chris Lee | Date: | Wed, 10 Oct 2001 14:47:51 +0000 |
| Subject: | Re: comparison problem | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-general+get-70676@lists.php.net to get a copy of this message | ||
I would check the values of $klok_int and $klok_dec variables, make sure
they are being set correctly.
print_r($klok_int);
print_r($klok_dec);
you can clean you code too by doing this. its just more ledgible.
function reassign($dec)
{
if ( $dec > 75 OR !$dec )
return 0;
if ( $dec > 50 )
return 75;
if ( $dec > 25 )
return 50;
if ( $dec > 0 )
return 25;
}
$klok_dec = reassign($klok_dec);
--
Chris Lee
lee@mediawaveonline.com
"Bart Verbeek" <b.verbeek@creative-edge.nl> wrote in message
news:KDEGLILLMKMDKJGAMGHIKEKCCEAA.b.verbeek@creative-edge.nl...
>
> Hello people,
>
> I seem to have a problem with comparing a few values.
> I'm queriing the db for $row_uren[uren] and $row_uren[uren_verbruikt]
> $uren_tegoed = the difference between [uren] and [uren_verbruikt] from the
> db.
>
> Than I split up $uren_tegoed in $uren_int (whole numbers) and $uren_dec
> (decimals).
> I want to check if the decimals and if they are
> - between 01 and 25 it has to be set to 25
> - between 26 and 50 it has to be set to 50
> - between 51 and 75 it has to be set to 75
> - between 76 and 99 or is 00 it has to be set to 00
>
> <?PHPCODE
> #AANTAL UREN SPLITTEN (INT/DEC) EN KLOKJES WEERGEVEN
> $uren_tegoed = $row_uren["uren"] - $row_uren["uren_verbruikt"];
>
> list ($klok_int, $klok_dec) = split('.', $uren_tegoed);
> if ($klok_dec >= "01" AND $klok_dec <= "25") {
> $klok_dec = "25";
> $klok_dec_image = "klok_4-1.gif";
> } elseif ($klok_dec >= "26" AND $klok_dec <= "50") {
> $klok_dec ="50";
> $klok_dec_image = "klok_4-2.gif";
> } elseif ($klok_dec >= "51" AND $klok_dec <= "75") {
> $klok_dec ="75";
> $klok_dec_image = "klok_4-3.gif";
> } elseif ($klok_dec >= "76" AND $klok_dec <= "99" || $klok_dec ==
> "0" ||
> !isset($klok_dec)) {
> $klok_dec ="0";
> $klok_dec_image = "klok_4-0.gif";
> --$klok_int;
> } else {
> $klok_dec ="ERROR";
> $klok_dec_image = "ERROR";
> }
> PHPCODE?>
>
> I keep getting the ERROR at the bottom of the page.
>
> Can anyone help me with this??
>
> Thanks in advance..
>
> Bart
>