> //for each row I want to add percentage as new key->value pair
>                         // but it gives error 'Undefined variable:
> percentage'
>                $row->$percentage = ($browseCount / $totalCount ) * 100;

Obviously you get the error because $percentage is not defined ..

I did not fully understand what you wanted.

Here is a list of what should work ...

#Set a variable percentage in $row
$row->percentage = ($browseCount / $totalCount ) * 100;

#Set a variable with name $percentage in $row
$percentage = ($browseCount / $totalCount ) * 100;
$row->$percentage = $percentage;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to