Why does the page prompt that the variable ImgList is not defined?
Jerry
Jerry 2018-01-29 14:20:21
0
8
2024

Modified based on the teacher’s gradeList

public function imgList()
{
$Image = img_tb::all();

$count = img_tb::count ( ); $value->name,
                                                                                                                                                           ] = $data;
}
$this->view->assign('imgList',$ImgList);
$this->view->assign('count',$ count);
//Render image list template
return $this -> fetch('img_list');
}

Jerry
Jerry

reply all(2)
宇瞳

Define $i=0 before foreach;


$ImgList[$i] = $data;

$i++;

That’s it

  • reply Add $ImgList=array(); in front of it.
    宇瞳 author 2018-05-10 23:53:02
lge

Then try declaring this variable before and assign it to empty.

  • reply It is true that no error is reported, but the database data cannot be displayed on the page.
    Jerry author 2018-01-30 13:38:06
  • reply The variables read out, the output array is empty
    Jerry author 2018-01-30 13:41:55
  • reply foreach ($Image as $value) { $data = [ 'id' => $value->id, 'name' => $value->name, 'img' => $value->img, 'create_time' => $value->create_time, 'update_time' => $value->update_time, ]; $imgList[] = $data; dump($data); } This is what I output. Where can I see the output?
    Jerry author 2018-01-30 14:01:16
  • reply Print the variable to see if it has a value
    韦小宝 author 2018-01-30 13:40:42
  • reply Print $data and see if there is any value. By the way, your $ImgList is empty and is best placed at the front of the method.
    韦小宝 author 2018-01-30 13:43:06
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template