PHP_the 16th day

沉寂了一段时间,总算是开始了新的学习,步入框架时代;

第一步,学习smarty框架;

M: model类;

V:view视图(静态模板);

C:control(核心,PHP);

实现PHP代码和前端代码分离;

初步改造--省市县三级联动:

<?php
    require("mysql.class.php");
    require("./smarty/Smarty.class.php");
    
    $smarty = new Smarty();
    $smarty->cache_dir = "./cache";
    $smarty->compile_dir = "./compile";
    $smarty->template_dir = "./template";
    
    $provinceList = $mysql->getAll( "SELECT * FROM ecs_region WHERE parent_id = 1" );    
    
    $smarty->assign("provinceList",$provinceList);            
    $smarty->display("index.html");            //渲染

?>


<select name="province" id="province">
        <option value="0">请选择省</option>

        {foreach $provinceList as $k => $v}

        <option value="{$v.region_id}">{$v.region_name}</option>

        {/foreach}

</select>

<select name="city" id="city">
        <option value="0">请选择市</option>
</select>
<select name="district" id="district">
        <option value="0">请选择县</option>
</select>

接下来,继续改造之前项目--信息管理系统;

未来的路,任重而道远,我有许多憧憬,全凭自己拼搏;

猜你喜欢

转载自blog.csdn.net/weixin_42031763/article/details/80858773