卡號 日期 签到 签退
   李俊峰 (Y00353 )     
2305318 2012/5/17 07:52:00
2305318 2012/5/17 19:56:00
2305318 2012/5/18 07:53:00
2305318 2012/5/18 18:02:00
   劉雲雲 (Y00382 )     
16734746 2012/5/17 07:44:00
16734746 2012/5/17 19:57:00
16734746 2012/5/18 07:44:00
16734746 2012/5/18 18:03:00
   嚴斌 (Y00387 )     
16734171 2012/5/17 07:55:00
16734171 2012/5/17 19:56:00
16734171 2012/5/18 07:56:00
16734171 2012/5/18 18:03:00

解决方案 »

  1.   

    试试:
    select 卡號,日期 group_concat(签到,签退) from tt group by 卡號,日期 ;
      

  2.   

    [User:root Time:13:16:11 Path:/home/liangdong/php]$ php bin.php 
    Array
    (
        [李俊峰 (Y00353 )] => Array
            (
                [2305318 2012/5/17] => Array
                    (
                        [0] => 07:52:00
                        [1] => 19:56:00
                    )            [2305318 2012/5/18] => Array
                    (
                        [0] => 07:53:00
                        [1] => 18:02:00
                    )        )    [劉雲雲 (Y00382 )] => Array
            (
                [16734746 2012/5/17] => Array
                    (
                        [0] => 07:44:00
                        [1] => 19:57:00
                    )            [16734746 2012/5/18] => Array
                    (
                        [0] => 07:44:00
                        [1] => 18:03:00
                    )        )    [嚴斌 (Y00387 )] => Array
            (
                [16734171 2012/5/17] => Array
                    (
                        [0] => 07:55:00
                        [1] => 19:56:00
                    )            [16734171 2012/5/18] => Array
                    (
                        [0] => 07:56:00
                        [1] => 18:03:00
                    )        ))
    <?php
    $content = <<<EOF
    卡號    日期    签到    签退
       李俊峰 (Y00353 )     
    2305318 2012/5/17       07:52:00
    2305318 2012/5/17        19:56:00
    2305318 2012/5/18       07:53:00
    2305318 2012/5/18        18:02:00
       劉雲雲 (Y00382 )     
    16734746        2012/5/17       07:44:00
    16734746        2012/5/17        19:57:00
    16734746        2012/5/18       07:44:00
    16734746        2012/5/18        18:03:00
       嚴斌 (Y00387 )     
    16734171        2012/5/17       07:55:00
    16734171        2012/5/17        19:56:00
    16734171        2012/5/18       07:56:00
    16734171        2012/5/18        18:03:00
    EOF;function do_merge($content) {
            $rows = explode(PHP_EOL, $content);
            array_shift($rows);
            $len = count($rows);
            $result = array();
            for ($i = 0; $i != $len; ++ $i) {
                    $n = preg_match('/^\s/', $rows[$i], $matches);
                    if ($n != 0) {
                            $name = trim($rows[$i]);
                            $result[$name] = array();
                            continue;
                    }
                    $cols = preg_split('/\s+/', $rows[$i], -1, PREG_SPLIT_NO_EMPTY);
                    $key = $cols[0] . " " . $cols[1];
                    if (!isset($result[$name][$key])) {
                            $result[$name][$key] = array($cols[2]);
                    } else {
                            $result[$name][$key][] = $cols[2];
                    }
            }
            return $result;
    }$result = do_merge($content);
    print_r($result);
    ?>
      

  3.   

    [User:root Time:13:46:07 Path:/home/liangdong/php]$ cat bin.php 
    <?php
    $content = <<<EOF
    卡號    日期    签到    签退
       李俊峰 (Y00353 )     
    2305318 2012/5/17       07:52:00
    2305318 2012/5/17        19:56:00
    2305318 2012/5/18       07:53:00
    2305318 2012/5/18        18:02:00
       劉雲雲 (Y00382 )     
    16734746        2012/5/17       07:44:00
    16734746        2012/5/17        19:57:00
    16734746        2012/5/18       07:44:00
    16734746        2012/5/18        18:03:00
       嚴斌 (Y00387 )     
    16734171        2012/5/17       07:55:00
    16734171        2012/5/17        19:56:00
    16734171        2012/5/18       07:56:00
    16734171        2012/5/18        18:03:00
    EOF;function do_merge($content) {
            $rows = explode(PHP_EOL, $content);
            $head = array_shift($rows);
            $len = count($rows);
            $result = array();
            for ($i = 0; $i != $len; ++ $i) {
                    $n = preg_match('/^\s/', $rows[$i], $matches);
                    if ($n != 0) {
                            $name = trim($rows[$i]);
                            $result[$name] = array();
                            continue;
                    }
                    $cols = preg_split('/\s+/', $rows[$i], -1, PREG_SPLIT_NO_EMPTY);
                    $key = $cols[0] . " " . $cols[1];
                    if (!isset($result[$name][$key])) {
                            $result[$name][$key] = array($cols[2]);
                    } else {
                            $result[$name][$key][] = $cols[2];
                    }
            }
            $ret_content = $head . PHP_EOL;
            foreach ($result as $name => $details) {
                    $ret_content .= $name . PHP_EOL;
                    foreach ($details as $date => $times) {
                            $ret_content .= $date;
                            foreach ($times as $time) {
                                    $ret_content .= " " . $time;
                            }
                            $ret_content .= PHP_EOL;
                    }
            }
            return $ret_content;
    }$result = do_merge($content);
    echo $result;
    ?>
    [User:root Time:13:46:16 Path:/home/liangdong/php]$ php bin.php 
    卡號    日期    签到    签退
    李俊峰 (Y00353 )
    2305318 2012/5/17 07:52:00 19:56:00
    2305318 2012/5/18 07:53:00 18:02:00
    劉雲雲 (Y00382 )
    16734746 2012/5/17 07:44:00 19:57:00
    16734746 2012/5/18 07:44:00 18:03:00
    嚴斌 (Y00387 )
    16734171 2012/5/17 07:55:00 19:56:00
    16734171 2012/5/18 07:56:00 18:03:00
    [User:root Time:13:46:19 Path:/home/liangdong/php]$ 完整收拾的结果。
      

  4.   

    $query ="select a.icid,a.zgxm,a.bm1, b.zgbh,b.sksj from hp_zd01 a left join hv_kqsk b on(a.zgbh=b.zgbh) where  b.zgbh ='$ren[1]' and (sksj >= '$tim1' and sksj <= '$tim2') order by sksj ASC ";
    $rs=odbc_do($conn,$query);
    if (!$rs){echo "Sorry,Could not connect to server!";exit;}
    $ren[0] =stripslashes($ren[0]);
    echo "<tr><td colspan=11><strong>&nbsp;&nbsp; $ren[0] ($ren[1])&nbsp;&nbsp;&nbsp;&nbsp; </strong></td></tr>";
    while($row=odbc_fetch_array($rs)){
     $a=$row[sksj];
     $shijian=strtotime($a);//??成??戳
         $time=date("Y-m-d",$shijian);//格式化??
     $time1=date("H:i:s",$shijian);//shangxiabanshijian格式化??
     $time2=strtotime($time1);
     $fenzhong=date("H:i:s",$shijian);
     $shangwu=strtotime("12:00:00");
    ?>

     <tr bgcolor=#FFEEEE>
      <td width=5%><div align=center><?php echo $row[icid];?></div></td>
                          <td width=10%><div align=center><?php echo $time;?></div></td>
      <td width=10%><div align=center><?php if($time2<$shangwu){echo $fenzhong;} ?></div></td>
        <td width=10%><div align=center><?php if($time2>$shangwu){echo $fenzhong;} ?></div></td>
      <td width=10%><div align=center>00:00:00</div></td>
      <td width=10%><div align=center>00:00:00</div></td>
                    </tr>
    <?php 
    }

    }

    }
    ?>
    我是这样子显示的,你给的代码我不知道怎么套用,还请详细答案感谢!本人是没有学过php是刚接触的,有点摸不到头脑,感谢了!