Welcome Guest, Not a member yet? Register   Sign In
Something wierd here
#1

[eluser]Todlerone[/eluser]
Hello everyone and TY in advance. For the life of me I can't figureout why this will not work (I'm sure is sooooo simple...but OMG I think I'm brain dead).

This is in a view with some $data. Here is the output of the $plan_fract array. I have used and end() function in the controller to always get the last row in the database so my array will always only contain data like below (ie, one row).
Code:
Array
(
    [plan_fraction_num] => 1
    [plan_fraction_partial_fraction] => No
    [plan_fraction_pct_deli] =>
    [plan_fraction_pct_total] =>
)

I'm trying to do this...
Code:
echo '<pre>'; print_r($plan_fract); echo '</pre>';

foreach ($plan_fract as $pf):
        echo "partial=".$pf['plan_fraction_partial_fraction']."<br />";
    if ($pf['plan_fraction_partial_fraction'] == 'No'){
        $fract = $pf['plan_fraction_num']+1; // increase 1 to 2, 2 to 3....
    }
    if ($pf['plan_fraction_partial_fraction'] == "Yes"){
        $len = strlen($pf['plan_fraction_num']);// the num can also be 1m1, 1m2...
        if ($len == 1){
            $fract = $pf['plan_fraction_num'].'m1';//if previous was 1, the new is 1m1
        }
        if ($len == 3){//if 1m1, 1m2, 1m3, 2m1....
            $frac_NUMs = substr($pf['plan_fraction_num'], 0,2);// get the first two char 1m
            $frac_NUMe = substr($pf['plan_fraction_num'], -1);//get the last char
                $fract = $frac_NUMs.($frac_NUMe+1);// increase the last only
        }
            
            }
            //echo $fract;
        endforeach;

I get this as an output...
partial=1
partial=N
partial=
partial=


I never get into my if loops, so I added the echo partial to see what it was seeing....


Messages In This Thread
Something wierd here - by El Forum - 05-10-2011, 02:50 PM
Something wierd here - by El Forum - 05-11-2011, 12:28 AM
Something wierd here - by El Forum - 05-11-2011, 08:09 AM
Something wierd here - by El Forum - 05-11-2011, 08:16 AM
Something wierd here - by El Forum - 05-11-2011, 08:19 AM
Something wierd here - by El Forum - 05-11-2011, 08:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB