I am using the following code for the output of mysql table value:
echo $result[0]->column1;
Now I want to perform some simple maths by using 2 columns of the table. I have tried the following code but it is not working:
echo $result[0]->(column1 / column2 * 100);
Advertisement
Answer
column1 and column2 are the field names (properties of an object) of $result[0] so what you would like to do is:
echo $result[0]->column1 / $result[0]->column2 * 100;