[英]Code Igniter: A PHP Error was encountered Severity: Notice Message: Undefined variable: page Filename: admin/display_page.php Line Number: 18
I'm getting the following error inside the admin page where I can view the table containing all the pages: 我在管理页面内看到以下错误,我可以在其中查看包含所有页面的表:
A PHP Error was encountered Severity: Notice
遇到PHP错误严重性:注意
Message: Undefined variable: page
消息:未定义的变量:页面
Filename: admin/display_page.php
文件名:admin / display_page.php
Line Number: 18
行号:18
Any idea what I should change? 知道我应该改变什么吗? the code inside display_page.php is similar to the display_news.php but for some reason, the backend page related to the pages shows an error and the one for the news is working fine.
display_page.php中的代码与display_news.php类似,但是由于某些原因,与页面相关的后端页面显示错误,并且该新闻页面工作正常。
That's the code inside display_page.php: 那是display_page.php中的代码:
<form name="listing" id="listing" action="<?php echo base_url(); ?>admin/page/delete" method="post">
<input name="lang" type="hidden" value="<?php echo $lang;?>" />
<table width="900" border="0" cellspacing="0" cellpadding="0" class="listingTbl">
<tr>
<th width="100">Page Id</th>
<th>Page Title</th>
<th width="150"><a class="filter-column" href="?sort=page_group">Page Group</a></th>
<th width="100">Actions</th>
</tr>
<?
foreach($page_s as $page){?>
<tr>
<td><?php echo $page["page_id"];?> </td>
<td><?php echo $page["page_title"];?> </td>
<td><?php echo $page["page_group"];?> </td>
<td>
<a href="<?php echo base_url(); ?>admin/page/action/<?php echo $page["lang"];?>/<?php echo $page["page_id"];?>">
<img src="<?php echo base_url(); ?>admin_images/edit.png" width="16" height="16" />
</a>
</td>
</tr>
<? }?>
</table>
</form>
<div id="delete-block"><a href="#" id="delete-items"><img src="<?php echo base_url(); ?>admin_images/drop.png" width="16" height="16" align="absmiddle" > Delete Checked Items</a></div>
<div id="pagination-block">Go to <?php echo $this->pagination->create_drop_down();?></div>
EDIT: 编辑:
That's the code related to the pages in the controller file: 那是与控制器文件中的页面相关的代码:
function index()
{
$sort = isset($_GET['sort']) ? $_GET['sort'] : null;
$lang = ( isset($this->uri_arr["lang"]) ) ? $this->uri_arr["lang"] : "en";
///////////////////////////////////////////////////////////
$current_page = (isset($this->uri_arr["page"])) ? $this->uri_arr["page"] : 1 ;
$per_page = "20";
$offset = ($current_page-1) * $per_page;
$config["base_url"] = base_url()."admin/page/index/";
$config["total_rows"] = $this->Page_model->num_page_s(array( "lang" => $lang ));
$config['per_page'] = '20';
$this->pagination->initialize($config);
///////////////////////////////////////////////////////////
$order_by = (isset($sort) && $sort == 'page_group') ? 'page_group ASC' : null;
$pages = $this->Page_model->get_all_page_s( $per_page , $offset , $lang, $order_by );
$this->load->vars( array( "page_s" => $pages, "lang" => $lang ));
$this->data["main_content"] = $this->load->view( "admin/display_page" , "" , TRUE );
$this->load->view( 'admin/template' , $this->data );
}
My guess is you don't have short_open_tag
enabled and so this line :- 我的猜测是您没有启用
short_open_tag
,所以这一行:-
<? foreach($page_s as $page){?>
isn't working. 不起作用。 You would need to change it to this:-
您需要将其更改为:-
<?php foreach($page_s as $page){ ?>
add this line to your controller when loading view pass $data
variable to view. 在加载视图时将此行添加到您的控制器,并传递
$data
变量到视图。
$data['page_s']=$your_array;
$this->load->view('file_path/file_name',$data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.