0

我正在为 PHP 文件中的 smarty 模板分配一个值。我的 PHP 文件中的代码片段如下:

<?php  
  require_once("includes/public-application-header.php");

  ob_start();
  prepare_request();
  $request = empty( $_GET ) ? $_POST : $_GET ;
  $op = $request['op'];
  $objTeacherDetails = new TeacherDetails();
  $teacher_id = $_GET['teacher_id'];
  $teacher_classes = $objTeacherDetails->GetAllClassesByTeacherId($teacher_id);
    $smarty->assign('teacher_classes', $teacher_classes);
  $file_to_show = "teacher-details.tpl";

switch( $op ) {
    case "get_assigned_subject_list":
        $objClassSubjects = new ClassSubjects();
        $objSubjects = new Subjects();
        $class_id  = $request['class_id'];
        $all_subjects = $objSubjects->GetAllSubjects();
        $subject_details = $objClassSubjects-> GetClassSubjectDetailsById($class_id);

        $smarty->assign('all_subjects', $all_subjects);
        $smarty->assign('subject_details', $subject_details);
        $smarty->assign('teacher_id', $teacher_id); 
        $smarty->display("assigned-subject-list.tpl");

        die();
        break;
?>

我的问题是我无法访问$teacher_idsmarty 模板中的值。我的 smarty 模板代码如下:

<input type="text" value="{$teacher_id}" name="tid">

但我让文本字段空白。谁能帮我解决这个小问题?提前致谢

4

1 回答 1

1

你有没有分配$smarty到某个地方?

$smarty = new Smarty();

编辑:

问题是$_GET['teacher_id']没有从一个页面调用传递到下一个页面调用。

于 2013-05-23T13:57:45.683 回答