-5

This is the JavaScript code,

var tabledata = [
 {id:1, name:"Oli Bob", age:"12", gender:"male", height:1, col:"red", dob:"", cheese:1, lucky_no:5},
 {id:2, name:"Mary May", age:"1", gender:"female", height:2, col:"blue", dob:"14/05/1982", cheese:true, lucky_no:10},
 {id:3, name:"Christine Lobowski", age:"42", height:0, col:"green", dob:"22/05/1982", cheese:"true", lucky_no:12},
 {id:4, name:"Brendon Philips", age:"125", gender:"male", height:1, col:"orange", dob:"01/08/1980", lucky_no:18},
 {id:5, name:"Margret Marmajuke", age:"16", gender:"female", height:5, col:"yellow", dob:"31/01/1999", lucky_no:33},
 {id:6, name:"Frank Harbours", age:"38", gender:"male", height:4, col:"red", dob:"", cheese:1, lucky_no:2},
 {id:7, name:"Jamie Newhart", age:"23", gender:"male", height:3, col:"green", dob:"14/05/1985", cheese:true, lucky_no:63},
 {id:8, name:"Gemma Jane", age:"60", height:0, col:"red", dob:"22/05/1982", cheese:"true", lucky_no:72},
 {id:9, name:"Emily Sykes", age:"42", gender:"female", height:1, col:"maroon", dob:"11/11/1970", lucky_no:44},
 {id:10, name:"James Newman", age:"73", gender:"male", height:5, col:"red", dob:"22/03/1998", lucky_no:9},
];
this is my php code :

<?php $arr1 = array (
array('id'=>'1', 'name'=>'Oli Bob','age'=>'12', 'gender'=>'male','height'=>'1','col'=>'red','dob'=>'', 'cheese'=>'1','lucky_no'=>'5'),
array('id'=>'2', 'name'=>'Mary May','age'=>'1', 'gender'=>'female','height'=>'2','col'=>'blue','dob'=>'14/05/1982', 'cheese'=>'true','lucky_no'=>'10')
);?>

and javascript :

var tabledata = "<?php json_encode($arr1);?>";

Please Help...? :(

my qustion is, in php code to javascript maybe wrong in my try..! the javascript code is the fixed code like my first post.

Mike
  • 11
  • 4

1 Answers1

-1

i assume you are looking for json_encode, but your question is very vague.

edit: now that you've updated this a bit. first, try

var tabledata = "<?php echo json_encode($arr1); ?>";

javascript needs to have some kind of output from the php, and without the echo, or something comparable, you don't have that.

Bobert123
  • 103
  • 8