du94414 2013-09-20 00:54
浏览 23
已采纳

如果数据库表为空,则阻止显示删除按钮? [关闭]

How can I hide the delete button with this array if $count > 0. Is there a way inside the PHP code to do this? Can someone help? I'm also open for anyone who wants to revise the code to be more secure.

<form action="checkbox.php" method="post">

<?php
$query = "SELECT filmTitle, filmRole, filmDirector, idfilm FROM filmInfo, actorsInfo
WHERE (actorsInfo.id = filmInfo.id_actor) AND email = '$_SESSION[email]'";

$result = mysql_query($query);
$count=mysql_numrows($result);

if($count > 0){
echo "<table>";

echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";   
echo "<tr style='font-weight: bold;'>";   
echo "
    <td width='20' align='center'>#</td>
    <td width='200' align='center'>TITLE</td>
    <td width='200' align='center'>ROLE</td>
    <td width='200' align='center'>DIRECTOR</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"];


  echo"<tr>";
  echo '<td><input name="checkbox[]" value="'.$idfilm.'" type="checkbox" 
    id="checkbox'.$row_number.'" /></td>';


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

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

  ?>

  <input type="submit" name="deletefilm" value="Delete" />
  </form>
  • 写回答

1条回答 默认 最新

  • duanjianfu1398 2013-09-20 01:01
    关注
    if($count > 0){
    
        echo "<table>";
    
        echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";   
        echo "<tr style='font-weight: bold;'>";   
        echo    "
    
        <td width='20' align='center'>#</td>
    
        <td width='200' align='center'>TITLE</td>
        <td width='200' align='center'>ROLE</td>
        <td width='200' align='center'>DIRECTOR</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"];
    
    
        echo"<tr>";
        echo '<td><input name="checkbox[]" value="'.$idfilm.'" type="checkbox" 
        id="checkbox'.$row_number.'" /></td>';
    
    
        for ($i=0; $i<3; $i++)  {
           echo"<td> $row[$i]</td>";
        }
        echo"</tr>";
    
        $row_number++;
        }
        echo"</table>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 Keil编译时报错"no source": Error: #5: cannot open source
  • ¥50 操作系统时间无法更新
  • ¥20 Windows11, usb转hdmi,外接显示器无反应
  • ¥20 怎么在JavaFx的TableView中动态地添加数据。
  • ¥15 MFC里的工具栏按钮图标使用外部图片
  • ¥15 如何在 llama.cpp 服务器中实现用户登录功能的优化方案?(语言-c++)
  • ¥15 有会用octave 的吗,急!代做!好偿!
  • ¥15 有一套同城小程序源码,Uniapp前端,php+html+mysql后端 ,能不能教我搭建起来可以运行,我不知道怎样操作
  • ¥15 mac调用java.io接口无法在根目录生成文件
  • ¥15 java微服务节点假死,网关路由时长延迟