last day (26 days later) » 

9:12 AM
0
A: I could not retrive values sent by controller in view file

mehuse row_array() instead of result_array() because result_array() returns the first value in index 0 and you should call: $tax[0]['company_tax13'];

 
Anu
yes it works.. but still few more doubts now it works for inclusive but not for exclusive... What may be the reason
 
meh
@anu what do you mean by inclusive and exclusive. please update your question and describe it.
 
Anu
I have updated my post please refer it @meh
 
meh
@Anu It's another question and I should know what is in service_detail session. $this->session->userdata('service_detail');. use =='true' instead of ==true.If it doesn't solve your problem ask it as a new question & let me know.
 
Anu
$this->session->userdata('service_detail') is a array that contains the service price and tax type. service price is a number and it works fine for me. but tax is a string. Using that i need to calculate tax
 
meh
9:12 AM
Does it have any string like 'inclusive' in it? read strstr() doc. php.net/strstr It doesn't return true. It returns anything after 'inclusive'. For example $string = 'inclusive123'; $a = strstr($string, 'inclusive'); The variable $a is 123
 
Anu
then how do i compare string in my code?
 
meh
if you want to see if 'inclusive' is in your string or not then you can use preg_match('/inclusive/', $string); it returns true if the word is in the string and false if not.
 
Anu
Can I use strcmp()
 
meh
why? it can be easily done with preg_match if it is a part of the string and if it is the whole, then you can compare whole words like if('a' == 'a') :-s
hi
 
Anu
i do not have much knowledge about codeigniter
I need to compare string
how can I do it?
 
meh
9:24 AM
it's really simple
$a = 'something';
$b = 'something';
if( $a == $b ) echo 'equal';
else
echo 'not equal';
 
Anu
ok so i will try this
 
meh
good luck ;)
 
Anu
<?php
$tax_percentage=$tax[0]['company_tax13'];
$tax_info = $service_detail['service_tax'];
$tax_type = "inclusive";
if($tax_info == $tax_type) {
$taxamount=$service_detail['service_price']-($service_detail['service_price']/(1+($tax_percentage/100)));
$grand=$service_detail['service_price'];
}
else{
$taxamount=($service_detail['service_price']*(1+($tax_percentage/100)))-$service_detail['service_price'];
$grand=$taxamount+$service_detail['service_price'];
}


?>
Is this ok?
here I am getting the tax_persentage from db
I am still not right.. I do not get any output
 

  last day (26 days later) »