生成每日交易注册

时间:2016-08-31 16:20:34

标签: php mysql

请知道,我需要协助如何为每天作为登记册,小组每天输入数据库的交易生成一个登记册。请参阅下面的代码:

选择标准:

<table width="70%" border="0" style="margin-top:15px;" align="left" class="table table-bordered">
    <thead>
        <tr>
            <th>S/N</th>
            <th nowrap="nowrap">FLT NO</th>
            <?php $list = array();
            $month = date('m');
            $year = date('Y');
            $dy = cal_days_in_month(CAL_GREGORIAN,date('n'),date('Y')); 

            for($d=1; $d<=$dy; $d++) {
                $time = mktime(12, 0, 0, $month, $d, $year);
                if (date('m', $time) == $month)
                    $list[]=date('Y-m-d', $time);
            }

            foreach ($list as $li){
                echo "<th>".$li."</th>";
            }?>
        </tr>
    </thead>
    <tbody>
        <?php if(isset($_POST['sbt'])){
            $loc = $_POST['loc'];
            $d1 = $_POST['d1'];  
            $d2 = $_POST['d2'];
            $c = 0;
            $st = mysqli_query($connection, "SELECT DISTINCT(fltno),created_at,id,status FROM tab_ddaily WHERE loc='$loc' AND CAST(created_at as date) BETWEEN '$d1' AND '$d2' ORDER BY fltno");
            while($r = mysqli_fetch_array($st)){
                $c++;?>
                <tr>
                    <td><?php echo $c;?></td>
                    <td nowrap="nowrap"><?php echo $r['fltno'];?></td>
                    <td nowrap="nowrap"><?php echo $r['status']=='Available'?'<img src="includes/images/pass.jpe" width="20" height="10" />':'<img src="includes/images/wrong.jpe" width="20" height="10" />';?></td>
                </tr>
            <?php }
        } else {
            $loc = "";
            $d1 = "";
            $d2 = "";
        }?>
    </tbody>
</table>

表格显示结果:

        Query<PreventionActivity> where = find.where(
            and(
                    and(
                    ge("Age_FROM", age)
                    , or(le("Age_TO", age), eq("Age_TO", 0))
                    )
                    , or(eq("Gender_CD", genderCd), eq("Gender_CD", "*"))
            )
    );

    List<PreventionActivity> list = where.findList();
    Logger.info("sql ");
    Logger.info(where.getGeneratedSql());

以上产生:enter image description here

我希望它产生:独特的FLT No连续,每天的状态从第1天到最后一天蔓延。请帮助我们如何实现这一目标。 请参阅下面的结构和数据: [![在此处输入图像说明] [2]] [2]

1 个答案:

答案 0 :(得分:1)

我修改了从数据库返回的输出数组,然后重复它以显示FLT和状态日期。

<tbody>
<?php if(isset($_POST['sbt'])){
    $loc = $_POST['loc'];
    $d1 = $_POST['d1'];  
    $d2 = $_POST['d2'];
    $c = 1;
    $st = mysqli_query($connection, "SELECT DISTINCT(fltno),created_at,id,status FROM tab_ddaily WHERE loc='$loc' AND CAST(created_at as date) BETWEEN '$d1' AND '$d2' ORDER BY fltno");

    $temp = array();
    while($r = mysqli_fetch_array($st)){
        $temp[ $r['fltno'] ][ $r['created_at'] ] = array('id' => $r['id'], 'status' => $r['status']);
    }

    foreach($temp as $key => $values){
        $dates = array_keys($values); ?>
        <tr>
            <td><?php echo $c;?></td>
            <td nowrap="nowrap"><?php echo $key;?></td>
            <?php foreach ($list as $li){
                if(in_array($li, $dates)){ ?>
                    <td nowrap="nowrap"><?php echo ($values[$li]['status'] == 'Available') ? '<img src="includes/images/pass.jpe" width="20" height="10" />':'<img src="includes/images/wrong.jpe" width="20" height="10" />';?></td>
                <?php } else{ ?>
                    <td nowrap="nowrap">n/a</td>
            <?php }
            } ?>
        </tr>
        <?php $c++;
    }
} else {
    $loc = "";
    $d1 = "";
    $d2 = "";
}?>
</tbody>

外循环是打印表行,SR_NO,FLT_NO和内循环是打印状态日期。

相关问题