亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

常用模板標(biāo)簽顯示用戶信息列表

Original 2019-04-10 13:26:08 278
abstrakt:Model類 <?php  namespace app\index\model; use think\Model;   class Staff extends Model { protected $table = 'staff'; protected 
Model類
<?php 
namespace app\index\model;
use think\Model;  

class Staff extends Model
{
	protected $table = 'staff';
	protected $pk = 'staff_id';
}
?>

Controller類
<?php 
namespace app\index\controller;
use think\Controller;
use app\index\model\Staff as StaffModel;

class Staff extends Controller
{
public function demo()
	{
		//分頁配置
		$config = [
			'type' => 'bootstrap',
			'var_page' => 'page',
			
		];

		//每頁數(shù)量
		$num = 5;

		//是否是簡(jiǎn)單分頁
		$simple = false;

		//獲取所有分頁數(shù)據(jù):返回值是分頁對(duì)象: think\Paginate
		$paginate = StaffModel::paginate($num, $simple, $config);

		//渲染分頁的HTML,返回分頁變量
		$page = $paginate->render();

		//將分頁對(duì)象賦值給模板
		$this->view->assign('staffs', $paginate);

		//將分頁變量賦值給模板
		$this->view->assign('page', $page);

		//渲染模板
		return $this->view->fetch();	

	}

}
?>

View類 demo.html
{load href="/static/bootstrap/css/bootstrap.css" /}

<div class="container">
	<div class="row">
		<h3 class="text-center">員工信息登記錄</h3>
		<div class="col-md-8 col-md-offset-2">
			<table class="table table-bordered table-hover text-center">
				<tr class="info">
					<td>ID</td>
					<td>姓名</td>
					<td>性別</td>
					<td>年齡</td>
					<td>工資</td>
				</tr>


				{empty name="staffs"}
					<h3 style="color: red;">當(dāng)前沒有符合條件的數(shù)據(jù)</h3>
				{else /}
				{volist name="staffs" id="staff"}
				<tr>
					<td>{$staff.staff_id}</td>
					<td>{$staff.name}</td>
					<td>
					{//性別必須是0或1,才是合法數(shù)據(jù)}
					{in name="staff.sex" value="0,1"}
						{if $staff.sex == 0}
							男
						{else /}
							女
						{/if}
					{/in}

					</td>
					<td>{$staff.age}</td>
					<td>{$staff.salary}</td>
				</tr>
				{/volist}
				{/empty}

			</table>
			<div class="text-center">{$page|raw}</div>
		</div>
	</div>
</div>

{load href="/static/jquery/jquery-3.3.1.js" /}
{load href="/static/bootstrap/js/bootstrap.js" /}


Korrigierender Lehrer:天蓬老師Korrekturzeit:2019-04-10 13:28:04
Zusammenfassung des Lehrers:控制器是用戶操作的入口, 也是url請(qǐng)求的重要數(shù)據(jù), 文件操作與表單要配合, 需要界面的

Versionshinweise

Beliebte Eintr?ge