0

如果 $count > 0,我如何用这个数组隐藏删除按钮。 PHP 代码中有没有办法做到这一点?有人可以帮忙吗?我也欢迎任何想要修改代码以提高安全性的人。

<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>
4

1 回答 1

1
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>";
}
于 2013-09-20T01:01:29.957 回答