我目前正在处理CodeIgniter图表,但收到的错误如下:
未捕获的SyntaxError:意外的标记<
图表未加载显示空白。
var data_course_stats = google.visualization.arrayToDataTable([
['Course', 'Time spent',{ role: 'style' }],
<?php
$i=0;
foreach ($timespent_stats as $course) { $course = (object)$course;
$color_val = 'green';
if(count($i<count($timespent_stats)))
$color_val = $colors[$i++];
?>
['<?php echo $course->title;?>', <?php echo $course->spent_seconds/60;?>,'<?php echo $color_val; ?>'],
<?php } ?>
]);
var options_course_stats = {
title: 'Course Wise Spent Time in Minutes',
curveType: 'function',
height: 400,
bar: {groupWidth: "50%"},
legend: { position: "none" },
};
答案 0 :(得分:1)
对于更长的块,为了保持PHP打开 - 你正在遇到麻烦,因为你正在混合和匹配打开和关闭。改变这个:
function onEdit(e){
var sheet = e.source.getActiveSheet().getName()
var editRow=e.range.getSheet().getActiveCell().getRow()
var editColumn=e.range.getSheet().getActiveCell().getColumn()
var ss = SpreadsheetApp.getActiveSpreadsheet()
var s=ss.getSheetByName("Show Management")//get sheet by name
var Ap=s.getRange(editRow,11,1,1).getValue()
if(sheet!="Show Management"){return}
if(editColumn==11 && editRow>=12 && Ap=="Approved"){
var d=s.getRange(editRow,27.1,1).getValue().toString()
if(d="[object Date]"){
var cpy=s.getRange(editRow,27 ,1, 1).getDisplayValue()
var cpyVal=s.getRange(editRow,27 ,1, 1).setValue(cpy)
}
}}
到此:
<?php
$i=0;
foreach ($timespent_stats as $course) { $course = (object)$course;
$color_val = 'green';
if(count($i<count($timespent_stats)))
$color_val = $colors[$i++];
?>
['<?php echo $course->title;?>', <?php echo $course->spent_seconds/60;?>,'<?php echo $color_val; ?>'],
<?php } ?>
答案 1 :(得分:0)
虽然你已经接受了答案,但我想添加另一种比前一种技术简单得多的技术。您可以使用<?=
<?php echo something; ?>
执行回音,这样您就可以执行此操作<?= something ?>
<?php
$i=0;
foreach ($timespent_stats as $course) {
$course = (object)$course;
$color_val = 'green';
if(count($i<count($timespent_stats)))
{
$color_val = $colors[$i++];
?>
[<?= $course->title ?>, <?= $course->spent_seconds/60 ?>, <?= $color_val ?>]
<?php
}
}
?>
答案 2 :(得分:0)
如果有人再次遇到此问题,请在config / config.php中检查您的base_url是否正确