create li according to a php array with javascript -
create li according to a php array with javascript -
i database php array looks this:
$dbresult= array([0]=>array([a]=>1 [b]=>1 [c]=>1) [1]=>array([a]=>2 [b]=>2 [c]=>2) [3]=>array([a]=>3 [b]=>3 [c]=>3) )
and in html ihave div id class
.
what create table phparray using javascript when label id="labletocreatetable" clicked, table should this
a b c 1 1 1 2 2 2 3 3 3
i know should utilize json_encode when result looks , im not pretty sure how utilize it
[{"a":"1","b":"1","c":"1"}, {"a":"2","b":"2","c":"2"}, {"a":"3","b":"3","c":"3"}]
i not sure wanted might helps you
<?php $dbresult= array(0=>array('a'=>1, 'b'=>1, 'c'=>1), 1=>array('a'=>2, 'b'=>2, 'c'=>2), 3=>array('a'=>3, 'b'=>3, 'c'=>3) ); echo '<table border=1><tr><td>'; echo implode('<td>',array_keys($dbresult[0])); foreach($dbresult $k =>$v){ echo '<tr>'; foreach ($v $k1 => $v1) { echo '<td>'.$v1.'</td>'; } echo '</tr>'; }
output
javascript php arrays
Comments
Post a Comment