I am new to PHP, jQuery and SQL, and I am trying to return data from my database to be used in my javascript file. For some reason, my object is being returned as a string even though values should be floating point numbers.
My database structure has this column setup to be a floating point number.
Here is a segment of my PHP code:
$q = "SELECT object FROM $tableName";
if($q === FALSE) {
die(mysql_error());
}
$sth = mysqli_query ($con, $q);
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
and here is my javascript:
$.get('PHP file URL', function(data) {
var object = JSON.parse(data);
However, I am getting the following (a string) returned instead of a floating point number:
[{"object":"34.416"},{"object":"34.589"},{"object":"33.3948"}]
I can't seem to find this same issue already posted. Please let me know what I am doing wrong. Thanks!