doumeng1143 2013-10-13 02:39
浏览 25

如果没有数据,在表中隐藏表?

I would like to know how to create this table within a table using the film.php only because I want it to not display a table background or table if $count is not > 0 ? Perhaps there is a way to just collapse the table automaticaly if there is nothing in it.

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

<tr><td>

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

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

Here is my film.php file?

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>";
  • 写回答

1条回答 默认 最新

  • douzongluo7542 2013-10-13 02:45
    关注

    Sure. Just combine the two like this:

    <?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>';
    }
    ?>
    

    And change the first part to just this:

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

报告相同问题?

悬赏问题

  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表