I'm Just fetching values from MySQL Database in php and in return it just neglecting .00 in last and converting float values in integer in php. but in my database all values are in float.. see my database screenshot
my php code below
public function GetSchemes(){
include "../includes/config.php";
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$sql = "SELECT * FROM ticket_info";
$post = $this->get_list_result($sql);
$respon = array(
'status' => 'ok','scheme' => $post
);
$this->response($this->json($respon), 200);
}
}
public function get_list_result($query) {
$result = array();
$r = $this->mysqli->query($query) or die($this->mysqli->error.__LINE__);
if($r->num_rows > 0) {
while($row = $r->fetch_assoc()) {
$result[] = $row;
}
}
return $result;
}
and I'm getting these values
{
"status": "ok",
"scheme": [
{
"id": 1,
"ticket_type": "Bumper",
"ticket_name": "p1",
"mrp": 250,
"selling_price": 225,
"series": 2,
"booklet": 20
},
{
"id": 2,
"ticket_type": "Bumper",
"ticket_name": "p2",
"mrp": 200,
"selling_price": 190,
"series": 10,
"booklet": 1
},
{
"id": 5,
"ticket_type": "Daily",
"ticket_name": "p3",
"mrp": 6,
"selling_price": 5.5,
"series": 5,
"booklet": 5
},
{
"id": 6,
"ticket_type": "Daily",
"ticket_name": "p4",
"mrp": 6,
"selling_price": 5.5,
"series": 25,
"booklet": 1
},
{
"id": 7,
"ticket_type": "Daily",
"ticket_name": "p5",
"mrp": 6,
"selling_price": 5.5,
"series": 50,
"booklet": 1
},
{
"id": 8,
"ticket_type": "Daily",
"ticket_name": "p6",
"mrp": 6,
"selling_price": 5.5,
"series": 100,
"booklet": 1
},
{
"id": 9,
"ticket_type": "Daily",
"ticket_name": "p7",
"mrp": 6,
"selling_price": 5.5,
"series": 200,
"booklet": 1
}
]
}
See in API Result mrp should be 250.00 but its showing 250 and selling_price should be 225.00 but its showing 225 i.e .00 in last is missing... but In my database.. .00 values are saved..
Why PHP is neglecting .00 values at last... I want to use .00 values
Thanks