I would like to make a timeline from a SQL query with the help of Google Charts. I have used the foillowing code to create the array, that encode to json. The problem is, that $table contains only the last record on the end of this code, but I have more than 1 record. I have used print_r for testing. It shows before the last line, that all the necessary rows are in the array. The problem is after the last line, after this it shows only one record with the column names, so some records are missing.
$rows = array(); $table = array(); $table['cols'] = array( array('id' => '', 'label' => 'Name', 'pattern' => '', 'type' => 'string'), array('id' => '', 'label' => 'Start', 'pattern' => '', 'type' => 'date'), array('id' => '', 'label' => 'End', 'pattern' => '', 'type' => 'date') ); while($r = mysql_fetch_assoc($results)) { $name=$r['Name']; $date=$r['Date']; $start=$r['start']; $end=$r['end']; $year=date("Y", strtotime($date)); $month=date("m", strtotime($date)); $day=date("d", strtotime($date)); $start_h=date("H", strtotime($start)); $start_min=date("i", strtotime($start)); $start_sec=date("s", strtotime($start)); $end_h=date("H", strtotime($end)); $end_min=date("i", strtotime($end)); $end_sec=date("s", strtotime($end)); $start_merged = "Date(".$year.",".$month.",".$day.",".$start_h.",".$start_min.",".$start_sec.")"; $end_merged = "Date(".$year.",".$month.",".$day.",".$end_h.",".$end_min.",".$end_sec.")"; $rows = array(); $temp = array(); $temp[] = array('v' => (string) $name); $temp[] = array('v' => (string) $start_merged); $temp[] = array('v' => (string) $end_merged); $rows[] = array('c' => $temp);} $table['rows'] = $rows; -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsubscr...@googlegroups.com. To post to this group, send email to google-visualization-api@googlegroups.com. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/d/optout.