不寻常的数据输出中断

时间:2015-09-08 21:41:23

标签: php css formatting

我一直在尝试确定我的PHP代码中的格式问题的来源。 mysql结果应显示前10行,我正在格式化。 LIMIT为10,但由于某种原因,在第9行和第10行之间存在数据中断。

我一直绞尽脑汁想弄清楚发生了什么。我附上了一张展示休息时间的图片。Gap

<?php
$conn = new mysqli('localhost', 'someuser', 'somepassword',    
'somedatabase');

// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());

}

// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}

// SELECT sql query
$sql = "SELECT c.*, s.species AS species1, b.breed AS breed1, m.modality 
AS modality1, a.area AS area1, cl.clinician AS clin FROM tbl_cases c

LEFT JOIN tbl_species s
ON c.species = s.speciesID

LEFT JOIN tbl_breed b
ON c.breed = b.breedID

LEFT JOIN tbl_modality m
ON c.modality = m.modalityID

LEFT JOIN tbl_area a
ON c.area = a.areaID

LEFT JOIN tbl_clinician cl
ON c.clinician = cl.clinicianID

ORDER BY date DESC
LIMIT 10"; 

// perform the query and store the result
$result = $conn->query($sql);

// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result

echo '<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 
5px;border-style:solid;border-width:1px;overflow:hidden;word-
break:normal;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-
weight:normal;padding:10px 5px;border-style:solid;border-
width:1px;overflow:hidden;word-break:normal;}
</style>
    <table class="tg" style="undefined;table-layout: fixed; width: 
1190px">
    <colgroup>
    <col style="width: 30px">  
    <col style="width: 125px">
    <col style="width: 100px">
    <col style="width: 250px">
    <col style="width: 80px">
    <col style="width: 200px">
    <col style="width: 50px">
    <col style="width: 180px">
    <col style="width: 175px">
    </colgroup>
  <tr>
    <th class="tg-031e">ID</th>
    <th class="tg-031e"><div align="left">Date:</div></th>
    <th class="tg-031e"><div align="left">Case No.:</div></th>
    <th class="tg-031e"><div align="left">Patient:</div></th>
    <th class="tg-031e"><div align="left">Species:</div></th>
    <th class="tg-031e"><div align="left">Breed:</div></th>
    <th class="tg-031e"><div align="left">Mod:</div></th>
    <th class="tg-031e"><div align="left">Area:</div></th>
    <th class="tg-031e"><div align="left">Clinician:</div></th>
  </tr>
</table>';
$c = false;
while($row = $result->fetch_assoc())   

{ 
echo '<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 
5px;border-style:solid;border-width:1px;overflow:hidden;word-
break:normal;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-
weight:normal;padding:10px 5px;border-style:solid;border-
width:1px;overflow:hidden;word-break:normal;} 
</style>
<table class="tg" style="undefined;table-layout: fixed; width: 1190px">
    <colgroup>
    <col style="width: 30px">  
    <col style="width: 125px">
    <col style="width: 100px">
    <col style="width: 250px">
    <col style="width: 80px">
    <col style="width: 200px">
    <col style="width: 50px">
    <col style="width: 180px">
    <col style="width: 175px">
    </colgroup>';

  if($row['modality']=='1') // Modality = CT
     echo '<tr bgcolor="#F0F8FF">
        <th><div align="left">'.$row['caseID'].'</div></th>
        <th><div align="left">'.date('d-M-Y',    
strtotime($row['date'])).'</div></th>
        <th><div align="left">'.$row['patientID'].'</div></th>
        <th><div     
align="left">'.$row['lastname'].',&nbsp;&nbsp;'.$row['firstname'].'</div>    
</th>
        <th><div align="left">'.$row['species1'].'</div></th>
        <th><div align="left">'.$row['breed1'].'</div></th>
        <th><div align="left">'.$row['modality1'].'</div></th>
        <th><div align="left">'.$row['area1'].'</div></th>
        <th><div align="left">'.$row['clin'].'</div></th>
        </tr>';

 else if($row['modality']=='2')// Modality = MRI
     echo '<tr bgcolor="#ECF6CE">
        <th><div align="left">'.$row['caseID'].'</div></th>
        <th><div align="left">'.date('d-M-Y', 
strtotime($row['date'])).'</div></th>
        <th><div align="left">'.$row['patientID'].'</div></th>
        <th><div 
align="left">'.$row['lastname'].',&nbsp;&nbsp;'.$row['firstname'].'</div>   
</th>
        <th><div align="left">'.$row['species1'].'</div></th>
        <th><div align="left">'.$row['breed1'].'</div></th>
        <th><div align="left">'.$row['modality1'].'</div></th>
        <th><div align="left">'.$row['area1'].'</div></th>
        <th><div align="left">'.$row['clin'].'</div></th>
        </tr>
    </table>';
  }
}
else {
  echo 'No cases.';
}
$conn->close();
?>

0 个答案:

没有答案