hi there im having a problem adding values to my graph from php array to javascript object so far i have a php values in the array
$data=array(5,10,15,20);
and i converted it to json to prepare for javascript
$js_array = json_encode($data);
and heres the javascipt part
data : <?php echo json_encode( $data ); ?>
i think it is reading it as
data : [5] or data : [5101520]
it was suppose to read it as
data : [5,10,15,20]
thanks guys hoping you can help me
here is the php array storing
<?php
$data = array();
$que = "SELECT name FROM table1 ORDER BY date ASC";
$res = mysql_query($que, $con);
if(mysql_num_rows($res)>0){
while($row = mysql_fetch_array($res)){
$data[] = $row['name'];
}}
$js_array = json_encode($data);
?>'
here is the var dump data echo array(4) { [0]=> string(1) "5" 1=> string(2) "10" [2]=> string(2) "20" [3]=> string(2) "15" }
$data()=[5,10,15,20];
is valid php ???$data()=[5,10,15,20];
isn't valid PHP. It's close. Please show your actual output, not merely what you think it is.[1,2,3]
vs.array(1,2,3)
. That's all.