zoukankan      html  css  js  c++  java
  • html遍历数组来填充表格

    1.
    [root@yyjk templates]# cat addmqmonitor.html 
    <html>
    <head>
    	<title>运维平台</title>
    	<link rel="stylesheet" type="text/css" href="/static/Css/Monitor/addmqmonitor.css">
    	<link rel="stylesheet" type="text/css" href="/static/Css/Public/header.css">
    	<link rel="stylesheet" type="text/css" href="/static/Css/Public/menu.css">
    </head>
    <body>
    	<include file="Public:header"/>
    	<div class="content">
    		<include file="Public:menu"/>
    		<div class="con fl">
    			<form id="condition" action="/addmqmonitor/" method="post">
    				
    				<label class="condition">应用</label><input type="text" name="app" class="equipment_sz">
    				<label class="condition">队列管理器</label><input type="text" name="qmgr" class="equipment_sz">
    				<label class="condition">通道名称</label><input type="text" name="channel" class="equipment_sz">
                                    <br />
    				<label class="condition">IPADDR</label><input type="text" name="ipaddr" class="equipment_sz">
    				<label class="condition">PORT</label><input type="text" name="port" class="equipment_sz">
    				<label class="condition">队列监控阈值</label><input type="text" name="depth" class="equipment_sz">
    				<label class="condition">是否监控</label><input type="text" name="flag" class="equipment_sz">
                                    <br />
    				<input type="submit" value="设备添加" class="equipment_add_btn">
    			</form>
    		</div>
    	</div>
    </body>
    <script type="text/javascript" src="/static/Js/jquery-2.2.2.min.js"></script>
    <!-- <script type="text/javascript" src="/static/Js/Equipment/addEquipment.js"></script> -->
    </html>
    
    
    2. 直接调用addmqmonitor方法
    
    def addmqmonitor(req):
       print req.get_full_path()
       app= req.POST['app']
       qmgr= req.POST['qmgr']
       channel= req.POST['channel']
       ipaddr= req.POST['ipaddr']
       port= req.POST['port']
       depth= req.POST['depth']
       flag= req.POST['flag']
       conn= MySQLdb.connect(
            host='127.0.0.1',
            port = 3306,
            user='root',
            passwd='1234567',
            db ='DEVOPS'
            )
       cursor = conn.cursor()
       sql = "insert into mon_mq(name,qmgr,channel,ipaddr,port,depth,flag) values('%s','%s','%s','%s','%s','%s','%s')" % (app,qmgr,channel,ipaddr,port,depth,flag)
       cursor.execute(sql)
       conn.commit()
       a = cur.execute("select name,qmgr,channel,ipaddr,port,flag from  mon_mq" )
       info = cur.fetchall()
       print info
       print type(info)
       return render(req,'listmqinfo.html',{'info':info})
    
       
      添加成功后跳转到显示页面
      
      
      返回东西内容:
      Django version 1.11, using settings 'mysite.settings'
    Starting development server at http://0.0.0.0:9000/
    Quit the server with CONTROL-C.
    /addmqmonitor/
    ((u'u7535u7968u7cfbu7edf', u'QMEMBFE', u'SYSTEM.ADMIN.SVRCONN', u'10.3.244.1', u'1417', u'1'), 
    (u'u5927u5c0fu989du8d85u7ea7u7f51u94f6u524du7f6eu4e3bu673a', u'QMUMBFEA', u'SYSTEM.DEF.SVRCONN', u'10.2.239.2', u'1424', u'1'),
     (u'u5927u5c0fu989du8d85u7ea7u7f51u94f6u524du7f6eu5907u673a', u'QMUMBFEA', u'SYSTEM.DEF.SVRCONN', u'10.2.239.1', u'1424', u'1'), 
     (u'u4e0au6d77u540cu57ceu524du7f6eu673a', u'DSFSHTLCB', u'SYSTEM.DEF.SVRCONN', u'10.3.221.1', u'1415', u'1'),
     (u'u4e0au6d77u540cu57ceu524du7f6eu673a', u'SMPSHTLCB', u'SYSTEM.DEF.SVRCONN', u'10.3.221.1', u'1414', u'1'),
     (u'u8d22u653fu975eu7a0e', u'FS_TLYH_SEND', u'SYSTEM.ADMIN.SVRCONN', u'10.3.217.1', u'1419', u'1'),
     (u'u56fdu9645u7ed3u7b97', u'QM_CODE0123', u'CHL.SC.BANK0123', u'10.3.248.1', u'1419', u'1'), 
     (u'u56fdu9645u7ed3u7b97', u'QM_RCPMIS_613057100058_01', u'SVRCONN', u'10.3.248.1', u'9100', u'1'), 
     (u'TIPSu7cfbu7edf', u'QM_TIPS_613057100058_01', u'SYSTEM.ADMIN.SVRCONN', u'10.3.233.1', u'9009', u'1'),
     (u'u8d22u653fu975eu7a0e', u'LQQCZJ_SEND', u'SYSTEM.ADMIN.SVRCONN', u'10.3.217.1', u'4515', u'0'),
     (u'u8d22u653fu975eu7a0e', u'LQQCZJ_RECV', u'SYSTEM.ADMIN.SVRCONN', u'10.3.217.1', u'4514', u'1'), 
     (u'u8d22u653fu975eu7a0e', u'LQQCZJ_PLSEND', u'SYSTEM.ADMIN.SVRCONN', u'10.3.217.1', u'4517', u'1'),
     (u'u8d22u653fu975eu7a0e', u'LQQCZJ_PLRECV', u'SYSTEM.ADMIN.SVRCONN', u'10.3.217.1', u'4516', u'1'), 
     (u'u8d22u653fu975eu7a0e', u'LQQCZJ_GWKSEND', u'SYSTEM.ADMIN.SVRCONN', u'10.3.217.1', u'4522', u'1'), 
     (u'u8d22u653fu975eu7a0e', u'LQQCZJ_GWKRECV', u'SYSTEM.ADMIN.SVRCONN', u'10.3.217.1', u'4521', u'1'),
     (u'u8054u7f51u6838u67e5', u'QM_PICP_313345010019_01', u'SVRCONN', u'10.3.240.1', u'9010', u'1'), (u'aaa', u'bbb', u'cccc', u'ddd', u'eee', u'0'))
    <type 'tuple'>
    
    
    
    
    返回的多维数组交给listmqinfo.html页面
    3.
    [root@yyjk templates]# cat listmqinfo.html 
    <html>  
    <head>  
        <title>运维平台</title>  
        <link rel="stylesheet" type="text/css" href="/static/Css/Equipment/modifyBtn.css">  
        <link rel="stylesheet" type="text/css" href="/static/Css/Public/header.css">  
        <link rel="stylesheet" type="text/css" href="/static/Css/Public/menu.css">  
    </head>  
    <table border="10">
    {% for x in info %}  
    <tr>
    <th>{{x.0}}</th>
    <th>{{x.1}}</th>
    <td>{{x.2}}</td>
    <td>{{x.3}}</td>
    <td>{{x.4}}</td>
    <td>{{x.5}}</td>
    </tr>
    {% endfor %}  
    </table>
    
    
    表格遍历多维数组
    
    

  • 相关阅读:
    理解多线程引用自 http://eagletff.blog.163.com/blog/static/11635092820105158493975/
    Delphi 完全时尚手册之 Visual Style 篇 (界面不错) 转自http://blog.csdn.net/iseekcode/article/details/4733229
    .Delphi下的COM编程 详解Delphi下的COM编程
    TPerlRegEx, delphi 下的正则表达式
    delphi 下多线程 并发操作 数据库(数据库锁) 注意事项
    关于利用其它版本看QQ的是否隐身
    QQ空间的一些操作
    关于自动申请QQ
    千千静听播放时出现杂音,而用其他播放器却没有
    无锡之行
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349336.html
Copyright © 2011-2022 走看看