如何在一个表中使用两个

编程


我确信两件事,它对我的​​教授有用,但对我不起作用,并且确信错误来自下面代码中的 echo 部分,而不是来自其他地方。

为了让您亲自尝试,我在链接中提供了我的工作 http://agencedevoyages.tk/[^]

输入地址:abc@gmail.com
密码是:2
或使用您选择的新用户登录。

错误代码:

PHP
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Accueil</title>
</head>
<body>
<?php
if(isset($_SESSION['email']) AND isset($_SESSION['password']))
{
echo "<b>Bienvenue ".$_SESSION['prenom']." ".$_SESSION['nom']." !";
echo "<div align='right'><a align='right' href='deconnect.php'><button type='button'>Se déconnecter</button></a></div>";
?>
<table border="1" align="center">
<caption><b><h1>La liste des étudiants</h1></caption>
<tr><td align="center"><b>Photo</td>
<td align="center"><b>Matricule</td>
<td align="center"><b>Nom</td>
<td align="center"><b>Prénom</td>
<td align="center"><b>Adress</td>
<td align="center"><b>Birthday</td>
<td align="center"><b>E-mail</td>
<td align="center" colspan="2"><b>Option</td>
<td align="center"><b>Multiple Deletion</td>
<td align="center"><b>Upload</td></tr>
<?php
include 'connect.php';
$sql = "SELECT * FROM etudiant";
$res = mysqli_query($connect, $sql);
if (mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res))
{
echo "<tr><td>";
?>
<?php
if(empty($row['photo']))
{
?>
<img src='photos/image.jpg' width="100" height="100">
<?php
}
else
{
?>
<img src='photos/<?php echo $row['photo'] ?>' width="100" height="100">
<?php
}
echo "</td>";
echo "<td align='center'>".$row['matricule']."</td>";
echo "<td align='center'>".$row['nom']."</td>";
echo "<td align='center'>".$row['prenom']."</td>";
echo "<td align='center'>".$row['adresse']."</td>";
echo "<td align='center'>".$row['date_naissance']."</td>";
echo "<td align='center'>".$row['email']."</td>";
if($_SESSION['email']==$row['email'] OR $_SESSION['email']=='abc@gmail.com')
{
echo "<td><a href='modif.php?id=".$row['id']."'><button type='button'>Edit</button></a></td>";
echo "<td><a href='supp.php?id=".$row['id']."'><button type='button'>Delete</button></a></td>";

// error part 
echo "<form method='post' action='supp3.php'><td align='center'><input type='checkbox' name='sup[]' value='".$row['id']."'></td></form>";
echo "<form method='post' action='upload.php' enctype='multipart/form-data'><td align='center'><input type='file' name='fichier'><input type='submit' value='Confirm'></td><input type='hidden' name='id' value='".$row['id']."'></td></tr>";
}
}
echo "<tr><td colspan='9'></td><td colspan='1' align='center'><button>Multiple Deletion</button></td></tr></form>";
}
//end of error part

else
{
echo "<tr><td colspan ='10' align='center'>No users.</td></tr>";
$sql = "TRUNCATE etudiant";
$res = mysqli_query($connect, $sql);
}
?>
</table>
<p align="center"><a href="ajout.php"><button>Add a user</button></a></p>
<?php
}
else
{
echo "<div align='center'><b><h1>Not allowed.";
echo "<br><a href='index.php'><button type='button'>Back</button></a></div>";
}
?>
</body>
</html>

我尝试过的:

– 在多重删除回显条件下关闭

,而不是在上传条件下,使我能够删除多个用户但无法上传图片。
– 当我为两者保留它时也会发生同样的情况。
– 从多重删除回显中删除 并将其保留在 Uplaod 回显条件下,使我无法删除多个用户,但能够更改用户的图片(意味着上传有效,而删除无效)。
– 从两个条件中删除封闭的 使 MD 工作而不是 Upload。

仍在尝试找出一种方法让它们同时工作。

解决方案1

你所表现出来的肯定 没有 为你的教授工作:

  • 你不能筑巢 <form> 元素。 您的“上传”表单永远不会关闭,因此每个后续表单都嵌套在前一行的表单中。
  • A <form> 元素不能直接出现在 <tr> 元素。 仅有的 <td><th> 元素允许在 <tr> 元素。

首先,您需要移动 <form> 元素 里面<td> 元素,并确保它们以正确的顺序关闭。

超文本标记语言
<td><form> ... </form></td>

但是,尚不清楚您的复选框的用途。 如果您想提交多行的 ID,这将不起作用 – 每个表单将仅包含其自己行的复选框。

コメント

タイトルとURLをコピーしました