HTML / SQL表格式

时间:2019-07-08 21:07:54

标签: html sql perl

我有这个SQL查询,可以提取我需要的所有数据,并按照我喜欢的方式对其进行格式化,但是我缺少一列该数据不在数据库中。根据数据输出的内容,我希望将结果分组到某个存储桶(第1列)中。我已查询将所有MIST,STATES和HRS都拉到大于48HRS。如何将输出数据链接到其对应的组?有人可以帮我弄这个吗?谢谢。

我正在尝试做的Excel示例。

enter image description here

这是我的代码:

print "             
<div id='wrapper'>
        <nav class='navbar navbar-inverse navbar-fixed-top' role='navigation'>
            <div class='navbar-header'>
                <button type='button' class='navbar-toggle' data-toggle='collapse' data-target=''.navbar-ex1-collapse'>
                    <span class='sr-only'>Toggle navigation</span>
                    <span class='icon-bar'></span>
                    <span class='icon-bar'></span>
                    <span class='icon-bar'></span>
                </button>
                <a class='logo' href='#'>
                    <img src='images/ti-logo.png' alt='CoolAdmin' />
                </a>
                </div>
            <div class='collapse navbar-collapse navbar-ex1-collapse'>
                <ul id='active' class='nav navbar-nav side-nav'>

                    <li><a href='CriticalToolsMet.html'><i class='fa fa-globe'></i> METROLOGY</a></li>
                    <li><a href='CriticalToolsCMPIMP.html'><i class='fa fa-globe'></i> CMP/IMP</a></li>
                    <li><a href='CriticalToolsDIFFWET.html'><i class='fa fa-globe'></i> DIFF/WET</a></li>
                    <li><a href='CriticalToolsPHOTO.html'><i class='fa fa-globe'></i> PHOTO</a></li>
                    <li><a href='CriticalToolsPLASMA.html'><i class='fa fa-globe'></i> PLASMA</a></li>
                    <li><a href='CriticalToolsTHINFILM.html'><i class='fa fa-globe'></i> THINFILM</a></li>
                </ul>
                <ul class='nav navbar-nav navbar-right navbar-user'>
                    <li class='divider-vertical'></li>
                    <li>
                        <form class='navbar-search'>
                            <input type='text' placeholder='Search' class='form-control'>
                        </form>
                    </li>
                </ul>
            </div>
        </nav>
        <div id='page-wrapper'>
            <div class='row'>
                <div class='col-lg-12'>
                    <h1>Critical Dashboard <small>THINFILM</small></h1>

                </div>
                </div>
            <div class='row'>
                <div class='col-lg-12'>
                    <div class='panel panel-primary'>
                        <div class='panel-heading'>
                            <h3 class='panel-title'><i class='fa fa-bar-chart-o'></i> Fab Dashboard - DMOS5 </h3>
                        </div>
                        <table class='table'>
                            <thead>

                            <tr>
                                    <th>TOOLGROUP</th>
                                    <th>MISTI</th>
                                    <th>STATE</th>
                                    <th>HRS</th>

                                </tr>
                            </thead>
                    </div>";

$sqlstr="Select 
       g.entity as MISTI,
       t.cur_state      as STATE,
       ROUND(((SYSDATE-t.cur_state_dttm)*24),2) AS HRS

From Entity_Grp_Lst g
left outer join trk_id_def t
on g.facility = t.facility
and g.grp_type = t.grp_type
and g.entity=t.entity
and g.grp_type = '720'
WHERE t.cur_state NOT IN ('PROD','NM','TERM','NULL','IDLE', 'YER', 'I05', 'I07')
and Entity_Grp_type = '041'
and g.ENTITY_GRP in ('THINFILM')
and (g.entity like 'CV403%' or
g.entity like 'CV406%' or
g.entity like 'CV405%' or
g.entity like 'CV132%' or
g.entity like 'MT105%' or
g.entity like 'MT106%' or
g.entity like 'MT117%' or
g.entity like 'MT118%' or
g.entity like 'MTA08%' or
g.entity like 'MTA13%'  )



AND ROUND(((SYSDATE-t.cur_state_dttm)*24),2) > 48  
order by t.cur_state_DTTM desc

";
$sth = $dbh->prepare($sqlstr);
$sth->execute();
$sth->bind_columns(undef, \$TOOL_GROUP, \$MISTI, \$STATE, \$HRS);
my %tool_groups = (
  CV403 => 'ARC_SOUTH',
  CV405 => 'ARC_SOUTH',
  CV406 => 'ARC_SOUTH',
  CV132 => 'BPSG',
  MT105 => 'COBALT',
  MT106 => 'COBALT'
);
while($sth->fetch()) {
    while($sth->fetch()) {
    my $TOOL_GROUP;
if (exists $tool_groups{$MISTI}) {
  $TOOL_GROUP = $tool_groups{$MISTI};
} else {
  warn "Unknown tool group for MIST: $MISTI";
  next;
}

   print "

                            <tbody>
                                <tr class='row100 body'>
                                 <td class='cell100 column3'>$TOOL_GROUP</td>
                                    <td class='cell100 column1'><FORM ACTION='http://d5lxgenwebapp01z.dal.make.ti.com/get_de1_de2_misti_comments.pl' METHOD='POST' target='_blank' NAME='userInput2'>
        <INPUT TYPE='hidden' NAME='eq' MAXLENGTH='8' VALUE='$MISTI'>
              <INPUT TYPE='hidden' NAME='pages' SIZE='3' MAXLENGTH='2' VALUE='50'>
        <INPUT TYPE='submit' NAME='submit' VALUE='$MISTI'></form></td>
                                    <td class='cell100 column2 $STATE'>$STATE</td>
                                    <td class='cell100 column3'>$HRS</td>

                                </tr>

   </tr>";
}

print "</tbody>
                        </table>
                    </div>
                    <p >Email: <a href='mailto:?subject=CRITICAL TOOLS DASHBOARD WEBPAGE'>Ru
                                Med</a></p>
                </div>

                </div>
            </div>
        </div>
    </div>";
$sth->finish();
$dbh->disconnect();

print "


</body></html>";

1 个答案:

答案 0 :(得分:1)

它仍然不是很清楚,但是我认为解决方案是简单的哈希。如果您的代码中包含此代码:

my %tool_groups = (
  CV403 => 'ARC_SOUTH',
  CV405 => 'ARC_SOUTH',
  CV406 => 'ARC_SOUTH',
  CV132 => 'BPSG',
  MT105 => 'COBALT',
  MT106 => 'COBALT',
  # etc...
);

然后在循环中,您可以执行以下操作:

my $tool_group;
if (exists $tool_groups{$MISTI}) {
  $tool_group = $tool_groups{$MISTI};
} else {
  warn "Unknown tool group for MIST: $MISTI";
  next;
}

然后在输出中使用$tool_group

但是记录下the advice I gave you in response to your last question。您正在使生活变得更加艰难。

更新:但是,老实说,我认为这样的信息应该在数据库表中。只需添加一个包含“雾到工具组”映射的表,然后就可以通过将联接添加到SQL中来获取数据。