0

我想知道如何使用 film.php 在表格中创建此表格,只是因为如果 $count 不 > 0 我希望它不显示表格背景或表格?如果表格中没有任何内容,也许有一种方法可以自动折叠表格。

<table align="center" width="806" border="0" background="images/backg.jpg" cellpadding="4">

<tr><td>

<?php
include 'film.php';
?> 

</td></tr>
</table>

这是我的film.php 文件?

if($count > 0){
echo "<table>";
echo "<table border='0' width='800' align='center' >";

echo    "
     <td width='40%' align='center'></td>
<td width='20%' align='center'></td>
<td width='40%' align='center'></td>"; 
echo "</tr>";

$row_number = 1;
while ($row = mysql_fetch_array($result)) {

$id_actor= $row["id_actor"];
$idfilm= $row["idfilm"]; 
$filmTitle= $row["filmTitle"];
$filmRole= $row["filmRole"];
$filmDirector= $row["filmDirector"];

for ($i=0; $i<3; $i++)  {
   echo"<td><font color=\"white\"> $row[$i]</td>";
}
echo"</tr>";

$row_number++;
}
echo"</table>";
4

1 回答 1

0

当然。只需像这样将两者结合起来:

<?php
if($count > 0){
  echo '<table align="center" width="806" border="0" background="images/backg.jpg" cellpadding="4">';
  echo '<tr><td>';
  echo "<table>";
  echo "<table border='0' width='800' align='center'>";
  echo "<td width='40%' align='center'></td>
        <td width='20%' align='center'></td>
        <td width='40%' align='center'></td>"; 
  echo "</tr>";
  $row_number = 1;
  while ($row = mysql_fetch_array($result)) {
    $id_actor= $row["id_actor"];
    $idfilm= $row["idfilm"]; 
    $filmTitle= $row["filmTitle"];
    $filmRole= $row["filmRole"];
    $filmDirector= $row["filmDirector"];
    for ($i=0; $i<3; $i++)  {
      echo"<td><font color=\"white\"> $row[$i]</td>";
    }
    echo"</tr>";
    $row_number++;
  }
  echo "</table>";
  echo '</td></tr>';
  echo '</table>';
}
?>

并将第一部分更改为:

<?php
include 'film.php';
?> 
于 2013-10-13T02:45:49.570 回答