Hi everybody,Â
I am getting an odd behavior when I am trying to display a string column, called "Series Name", through a
google table chart.Â
You can find my php code below. Please note that if I drop the column "Series Name" everything works fine. Otherwise, the output tableÂ
displays only the first 5 rows. Specifically, leaving the mentioned column if I set LIMIT >= 5 no table chart is created.Â
Let me stress that this issue appears on a new VPS where php and mysql db have been installed. Same code works on my old VPS as expected.Â
Any ideas how to overcome this issue?
Thanks in advance,Â
Drigo
<?php
try {
/* Establish the database connection */
$conn = new PDO("mysql:host=localhost;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/* select relevant info for table googlechart */
$result_RTI_VS_W_TABLE = $conn->query("SELECT * FROM `video_series_rank_week` ORDER BY `Year` DESC, `WeekN` DESC, `Rank` ASC LIMIT 15");
$rows_RTI_VS_W_TABLE = array();
$table_RTI_VS_W_TABLE = array();
$table_RTI_VS_W_TABLE['cols'] = array(
/* Labels for your chart, these represent the column titles */
array('label' => 'Rank', 'type' => 'number'),
array('label' => 'Year', 'type' => 'string'),
array('label' => 'WeekN', 'type' => 'number'),
array('label' => 'Series Name', 'type' => 'string'),
array('label' => 'Total Historical Constrained Ad Avails', 'type' => 'number')
);
/* Extract the information from $result */
foreach($result_RTI_VS_W_TABLE as $r_RTI_VS_W_TABLE) {
$temp_RTI_VS_W_TABLE = array();
/* the following line will be used to get a table */
$temp_RTI_VS_W_TABLE[] = array('v' => (int) $r_RTI_VS_W_TABLE['Rank']);
/* Values */
$temp_RTI_VS_W_TABLE[] = array('v' => (string) $r_RTI_VS_W_TABLE['Year']);
$temp_RTI_VS_W_TABLE[] = array('v' => (int) $r_RTI_VS_W_TABLE['WeekN']);
$temp_RTI_VS_W_TABLE[] = array('v' => (string) $r_RTI_VS_W_TABLE['Series Name']);
$temp_RTI_VS_W_TABLE[] = array('v' => (int) $r_RTI_VS_W_TABLE['Total Historical Constrained Ad Avails']);
$rows_RTI_VS_W_TABLE[] = array('c' => $temp_RTI_VS_W_TABLE);}
$table_RTI_VS_W_TABLE['rows'] = $rows_RTI_VS_W_TABLE;
/* convert data into JSON format */
$jsonTable_RTI_VS_W_TABLE = json_encode($table_RTI_VS_W_TABLE);
} catch(PDOException $e) {echo 'ERROR: ' . $e->getMessage();}
?>