I've tried to convert my string array to INT by using intval But the result / return always int(1) while the database value was 14698
my database :
+-------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| curr | char(3) | NO | | NULL | |
| rate | int(11) | NO | | 0 | |
+-------+---------+------+-----+---------+----------------+
+----+------+-------+
| id | curr | rate |
+----+------+-------+
| 1 | USD | 1 |
| 2 | IDR | 14698 |
| 3 | JPY | 112 |
| 4 | EUR | 1 |
| 5 | THB | 33 |
+----+------+-------+
Here's my crudQuery.php page :
<?php
require 'config.php';
if (isset($_POST['save'])) {
require_once 'functions.php';
$qty = $_POST['qty'];
$qty = (int) $qty;
$curr = $_POST['curr'];
$price = $_POST['price'];
$price = (int) $price;
$rate = queryInt("SELECT rate FROM rate_master WHERE curr = '$curr'");
var_dump($rate);echo $rate[0];
here's my functions.php page :
<?php
require 'config.php';
function queryInt($query) {
global $conn;
$result = mysqli_query($conn, $query);
$rows = [];
while ($row = mysqli_fetch_assoc($result)) {
$rows [] = intval($row);
}
return $rows;
}
Then, the result of var_dump was :
array(1) { [0]=> int(1) } 1
What I suppossed to do, in order to return the value from database imstead of 1 ?
var_dump($rate);echo $rate[0];tovar_dump($rate);echo $rate[1];