PHP语言之MySQL操作

第3关:PHP实现下拉菜单显示数据 下

<?php
require "empUpdate.php";
if(!defined('APP')) die('error!');
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>员工信息编辑</title>
    <link rel="stylesheet" href="./js/jquery.datetimepicker.css"/ >
    <script src="./js/jquery.js"></script>
    <script src="./js/jquery.datetimepicker.js"></script>
    <script>
        $(function(){
            $('#date_of_birth').datetimepicker({lang:'ch'});
            $('#date_of_entry').datetimepicker({lang:'ch'});
        });
    </script>
    <style>
        body{background-color:#eee;margin:0;padding:0;}
        .box{width:400px;margin:15px auto;padding:20px;border:1px solid #ccc;background-color:#fff;}
        .box h1{font-size:20px;text-align:center;}
        .profile-table{margin:0 auto;}
        .profile-table th{font-weight:normal;text-align:right;}
        .profile-table input[type="text"]{width:180px;border:1px solid #ccc;height:22px;padding-left:4px;}
        .profile-table .button{background-color:#0099ff;border:1px solid #0099ff;color:#fff;width:80px;height:25px;margin:0 5px;cursor:pointer;}
        .profile-table .td-btn{text-align:center;padding-top:10px;}
        .profile-table th,.profile-table td{padding-bottom:10px;}
        .profile-table td{font-size:14px;}
        .profile-table .txttop{vertical-align:top;}
        .profile-table select{border:1px solid #ccc;min-width:80px;height:25px;}
        .profile-table .description{font-size:13px;width:250px;height:60px;border:1px solid #ccc;}
    </style>
</head>
<body>
<div class="box">
    <h1>修改员工信息</h1>
    <form method="post">
        <table class="profile-table">
            <tr><th>姓名:</th><td><input type="text" name="e_name" value="<?php echo $emp_info['e_name']; ?>"/></td></tr>
            <tr><th>所属部门:</th>
                <td>
                    <!—下拉菜单开始-->
                    <!—在输出每个部门信息时,判断是否为该员工当前所属部门,如果是设置为默认项selected='selected'-->
 					<!somecodes here-->
                    <select name="d_id">
                    <?php foreach ($emp_dept as $row){?>
                    <option value="<?php echo $row['d_id'];?>"><?php echo $row['d_name'];?></option>
                    <?php }?>
                    </select>
                    <!—下拉菜单结束-->
                </td></tr>
            <tr><th>出生年月:</th><td><input id="date_of_birth" name="date_of_birth" type="text" value="<?php echo $emp_info['date_of_birth']; ?>"></td></tr>
            <tr><th>入职日期:</th><td><input id="date_of_entry" name="date_of_entry" type="text" value="<?php echo $emp_info['date_of_entry']; ?>"></td></tr>
            <tr><td colspan="2" class="td-btn">
                    <input type="submit" value="保存资料" class="button" />
                    <input type="reset" value="重新填写" class="button" />
                </td></tr>
        </table>
    </form>
</div>
</body>
</html><?php
require "empUpdate.php";
if(!defined('APP')) die('error!');
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>员工信息编辑</title>
    <link rel="stylesheet" href="./js/jquery.datetimepicker.css"/ >
    <script src="./js/jquery.js"></script>
    <script src="./js/jquery.datetimepicker.js"></script>
    <script>
        $(function(){
            $('#date_of_birth').datetimepicker({lang:'ch'});
            $('#date_of_entry').datetimepicker({lang:'ch'});
        });
    </script>
    <style>
        body{background-color:#eee;margin:0;padding:0;}
        .box{width:400px;margin:15px auto;padding:20px;border:1px solid #ccc;background-color:#fff;}
        .box h1{font-size:20px;text-align:center;}
        .profile-table{margin:0 auto;}
        .profile-table th{font-weight:normal;text-align:right;}
        .profile-table input[type="text"]{width:180px;border:1px solid #ccc;height:22px;padding-left:4px;}
        .profile-table .button{background-color:#0099ff;border:1px solid #0099ff;color:#fff;width:80px;height:25px;margin:0 5px;cursor:pointer;}
        .profile-table .td-btn{text-align:center;padding-top:10px;}
        .profile-table th,.profile-table td{padding-bottom:10px;}
        .profile-table td{font-size:14px;}
        .profile-table .txttop{vertical-align:top;}
        .profile-table select{border:1px solid #ccc;min-width:80px;height:25px;}
        .profile-table .description{font-size:13px;width:250px;height:60px;border:1px solid #ccc;}
    </style>
</head>
<body>
<div class="box">
    <h1>修改员工信息</h1>
    <form method="post">
        <table class="profile-table">
            <tr><th>姓名:</th><td><input type="text" name="e_name" value="<?php echo $emp_info['e_name']; ?>"/></td></tr>
            <tr><th>所属部门:</th>
                <td>
                    <!—下拉菜单开始-->
                    <!—在输出每个部门信息时,判断是否为该员工当前所属部门,如果是设置为默认项selected='selected'-->
 					<!somecodes here-->
                    <select name="d_id">
                    <?php foreach ($emp_dept as $row){?>
                    <option value="<?php echo $row['d_id'];?>"><?php echo $row['d_name'];?></option>
                    <?php }?>
                    </select>
                    <!—下拉菜单结束-->
                </td></tr>
            <tr><th>出生年月:</th><td><input id="date_of_birth" name="date_of_birth" type="text" value="<?php echo $emp_info['date_of_birth']; ?>"></td></tr>
            <tr><th>入职日期:</th><td><input id="date_of_entry" name="date_of_entry" type="text" value="<?php echo $emp_info['date_of_entry']; ?>"></td></tr>
            <tr><td colspan="2" class="td-btn">
                    <input type="submit" value="保存资料" class="button" />
                    <input type="reset" value="重新填写" class="button" />
                </td></tr>
        </table>
    </form>
</div>
</body>
</html>

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

六弦绿漪。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值