我自己搞定了,不过作为标题的那栏需要循环输出2遍,有没有办法合并啊 代码如下: <?php include_once 'sqlconn.php';$js="select count(*) from jcxx where convert(char,jcrq,23)>='2010-12-15' and dwdm='0200049' and wcbz='9'"; $count = sqlsrv_query($conn,$js); if ( $ROW = sqlsrv_fetch_array( $count ) ) { $COUNT = $ROW[0]; echo '一共完成'."$COUNT".'人'; } if ($COUNT=='0') { echo "<br>"; die(没有检索到信息!); }$xh=1;$xh<=$COUNT; echo "<table border=\"1\">"; $Qjcxm=sqlsrv_query($conn,"select jcxm from jcxx,jcxx_jcxm where dwdm='0200049' and convert(char,jcxx.jcrq,23)='2010-12-15'and jcxx.studyid=jcxx_jcxm.studyid group by jcxm"); echo "<tr>"; echo "<td>序号</td>"; echo "<td>检查号</td>"; while ($ROW=sqlsrv_fetch_array($Qjcxm)) { $jcxm=$ROW[0]; echo "<td>$jcxm</td>"; } echo "</tr>"; $query="select studyid,convert(char,csny,23) as csny,convert(char,jcrq,23) as jcrq,xm,hf,xb,cktc,gzdm from jcxx where convert(char,jcrq,23)='2010-12-15' and dwdm='0200049' and wcbz='9' "; //查找JCXX$Result = sqlsrv_query($conn,$query); while($ROW = sqlsrv_fetch_array($Result)) { $studyid=$ROW['studyid']; $cktc=$ROW['cktc']; $gzdm=$ROW['gzdm']; $xm=$ROW['xm']; $hf=$ROW['hf']; $xb=$ROW['xb']; //查找JCXX $jcrq=$ROW['jcrq']; $csny=$ROW['csny']; $nl=date("Y-m-d",time())-$csny;
$Qjcxm1=sqlsrv_query($conn,"select jcxm from jcxx,jcxx_jcxm where dwdm='0200049' and convert(char,jcxx.jcrq,23)='2010-12-15'and jcxx.studyid=jcxx_jcxm.studyid group by jcxm"); echo "<tr>"; echo "<td>"; echo $xh++; echo "</td>"; echo "<td>$studyid</td>"; while ($ROW=sqlsrv_fetch_array($Qjcxm1)) { $jcxm=$ROW[0]; $Qjgtxt=sqlsrv_query($conn,"select jgtxt from jcxx_jcxm where studyid='".$studyid."' and jcxm='".$jcxm."'"); if ($ROW=sqlsrv_fetch_array($Qjgtxt)) { $jgtxt=$ROW[0]; } echo "<td>$jgtxt</td>"; } } echo "</tr>"; echo "</table>"; ?>
数组:$arr = array('row' => '2010', 'col' => 'zhangsan', 'num' => '¥5000');
样式控制$arr['row']在上面输出
样式控制$arr['col']在左面输出
样式控制$arr['num']在中间输出
当然了,也可能是多个数组
<?php
include_once 'sqlconn.php';$js="select count(*) from jcxx where convert(char,jcrq,23)>='2010-12-15' and dwdm='0200049' and wcbz='9'";
$count = sqlsrv_query($conn,$js);
if ( $ROW = sqlsrv_fetch_array( $count ) )
{
$COUNT = $ROW[0];
echo '一共完成'."$COUNT".'人';
}
if ($COUNT=='0')
{
echo "<br>";
die(没有检索到信息!);
}$xh=1;$xh<=$COUNT;
echo "<table border=\"1\">";
$Qjcxm=sqlsrv_query($conn,"select jcxm from jcxx,jcxx_jcxm where dwdm='0200049' and convert(char,jcxx.jcrq,23)='2010-12-15'and jcxx.studyid=jcxx_jcxm.studyid group by jcxm");
echo "<tr>";
echo "<td>序号</td>";
echo "<td>检查号</td>";
while ($ROW=sqlsrv_fetch_array($Qjcxm))
{
$jcxm=$ROW[0];
echo "<td>$jcxm</td>";
}
echo "</tr>";
$query="select studyid,convert(char,csny,23) as csny,convert(char,jcrq,23) as jcrq,xm,hf,xb,cktc,gzdm from jcxx where convert(char,jcrq,23)='2010-12-15' and dwdm='0200049' and wcbz='9' "; //查找JCXX$Result = sqlsrv_query($conn,$query);
while($ROW = sqlsrv_fetch_array($Result))
{
$studyid=$ROW['studyid'];
$cktc=$ROW['cktc'];
$gzdm=$ROW['gzdm'];
$xm=$ROW['xm'];
$hf=$ROW['hf'];
$xb=$ROW['xb']; //查找JCXX
$jcrq=$ROW['jcrq'];
$csny=$ROW['csny'];
$nl=date("Y-m-d",time())-$csny;
$Qjcxm1=sqlsrv_query($conn,"select jcxm from jcxx,jcxx_jcxm where dwdm='0200049' and convert(char,jcxx.jcrq,23)='2010-12-15'and jcxx.studyid=jcxx_jcxm.studyid group by jcxm");
echo "<tr>";
echo "<td>";
echo $xh++;
echo "</td>";
echo "<td>$studyid</td>";
while ($ROW=sqlsrv_fetch_array($Qjcxm1))
{
$jcxm=$ROW[0]; $Qjgtxt=sqlsrv_query($conn,"select jgtxt from jcxx_jcxm where studyid='".$studyid."' and jcxm='".$jcxm."'");
if ($ROW=sqlsrv_fetch_array($Qjgtxt))
{
$jgtxt=$ROW[0];
}
echo "<td>$jgtxt</td>";
}
}
echo "</tr>";
echo "</table>";
?>