I am trying to create a piechart dynamically by using Google Chart api. i am taking values from the database. I am not getting how exactly this can be done.
$resultViewed = $this->model_report_product->getMostViewed(); $stringResult ="var data= google.visualization.arrayToDataTable([ ['Product', 'Views'],"; foreach($resultViewed as $results) { $stringResult = $stringResult . "['".$results['name']."',".$results['quantity']."],"; break; } $stringResult .= "]);"; $this->data['Viewed'] = $stringResult; When i run this, it gives Chart heading but pie chart is not displayed but it says No Data.
mysql_*functions in new code. They were removed from PHP 7.0.0 in 2015. Instead, use prepared statements via PDO or MySQLi. See Why shouldn't I use mysql_* functions in PHP? for more information.