I already have checked similar answer. But i have different issue here!
TO create googlce char I am creating json string by fetching data from table. Table has only two rows. Here is how the json string is constructed:
$result = $mysqli->query('SELECT * FROM view_name');
$p= $mysqli->query('SELECT Index_val FROM view_name where ind_type=pcount');
//echo "$p";
$rows = array();
$table = array();
$table['cols'] = array(
array('label' => 'pcount', 'type' => 'string'),
array('label' => 'ncount', 'type' => 'number')
);
/* Extract the information from $result */
foreach($result as $r) {
$temp = array();
$temp[] = array('v' => (string) $r['ind_type']);
$temp[] = array('v' => (int) $r['Index_val']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
Here only two values I need to fetch from database pcount
and ncount
. I dont want to use above procedeure.
What I want is to fetch the values of pcount
and ncount
from table manually, store in variable and construct the json string.
Like this :
$p= $mysqli->query('SELECT Index_val FROM view_name where ind_type=pcount');
// Please correct if wrong
same way get get ncount
.
Now how can I create above json string from this? Resulting string will be like this:
{
"cols":[
{"label":"pcount","type":"string"},
{"label":"ncount","type":"number"}],
"rows":[
{"c":
[
{"v":"pcount"},
{"v":179} // 179 is pcount
]
},
{"c":
[
{"v":"ncount"},
{"v":285} //285 is ncount
]
}
]
}