我真的不知道如何解决这个问题。 每次我将这行代码添加到我的php文档中时,页面都会变成空白。 有没有人遇到过这个问题?
它在一张桌子里。显然它是 checked_id [] 数组。不知道如何修复它,它只会导致页面在添加时变为空白。
<td align="center"><input type="checkbox" name='.checked_id[];.' class="checkbox" value='.$row["id"].'</td>
这是整个街区。
$output .= '
<form name="bulk_action_form" action="delete_multiple.php" method="post" onSubmit="return delete_confirm();"/>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th width="10%">Id</th>
<th width="40%">Name</th>
<th width="40%">Email</th>
<th width="40%">Address</th>
<th width="10%">phoneNumber</th>
<th width="10%">appointmentTime</th>
<th width="10%">appointmentDate</th>
<th width="50%">message</th>
<th width="10%">delete</th>
<th><input type="checkbox" name="select_all" id="select_all" value=""/></th>
</tr>';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["id"].'</td>
<td class="name" data-id1="'.$row["id"].'" contenteditable>'.$row["name"].'</td>
<td class="email" data-id2="'.$row["id"].'" contenteditable>'.$row["email"].'</td>
<td class="address" data-id2="'.$row["id"].'" contenteditable>'.$row["address"].'</td>
<td class="phoneNumber" data-id2="'.$row["id"].'" contenteditable>'.$row["phoneNumber"].'</td>
<td class="appointmentTime" data-id2="'.$row["id"].'" contenteditable>'.$row["appointmentTime"].'</td>
<td class="appointmentDate" data-id2="'.$row["id"].'" contenteditable>'.$row["appointmentDate"].'</td>
<td class="message" data-id2="'.$row["id"].'" contenteditable>'.$row["message"].'</td>
<td><button type="button" name="delete_btn" data-id3="'.$row["id"].'" class="btn btn-xs btn-danger btn_delete">Delete</button></td>
<td><input type="checkbox" name="'.checked_id[].'" class="checkbox" value="'.$row["id"].'"/></td>
</tr>
';
}
}
else
{
$output .= '<tr><td colspan="4">Data not Found</td></tr>';
}
$output .= '</table>
</div></form>';
echo $output;
?>
答案 0 :(得分:1)
结构不合理:
像这样使用:
<input type="checkbox" name="'.checked_id[].'" class="checkbox" value="'.$row["id"].'"/></td>
^ ^ ^ ^ ^ ^^^
答案 1 :(得分:0)
首先,你必须将name='.checked_id[];.' class="checkbox" value='.$row["id"].
PHP变量转换成HTML,你不能只写出自己的名字,因为HTML不明白。
以下是第一行中的示例,您在大多数代码中都给出了相同的示例。
你的代码:
name='<?php echo checked_id[]; ?>' class="checkbox" value='<?php echo $row["id"]; ?>'
应该如何:
checked_id[]
另一件事,我认为name="<?php echo $somevariable; ?>"
应该是一个数组索引,你不能把它留空。如果我错了,请纠正我,并在整个页面中使用此示例,因为要显示PHP变量,您必须打开HTML并在此处回显您的变量<?php
$output .= "";
?>
<form name="bulk_action_form" action="delete_multiple.php" method="post" onSubmit="return delete_confirm();"/>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th width="10%">Id</th>
<th width="40%">Name</th>
<th width="40%">Email</th>
<th width="40%">Address</th>
<th width="10%">phoneNumber</th>
<th width="10%">appointmentTime</th>
<th width="10%">appointmentDate</th>
<th width="50%">message</th>
<th width="10%">delete</th>
<th><input type="checkbox" name="select_all" id="select_all" value=""/></th>
</tr>';
<?php
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
?>
<tr>
<td><?php echo $row["id"]; ?></td>
<td class="name" data-id1="<?php echo $row["id"]; ?>" contenteditable><?php echo $row["name"]; ?></td>
<td class="email" data-id2="<?php echo $row["id"]; ?>" contenteditable><?php echo $row["email"]; ?></td>
<td class="address" data-id2="<?php echo $row["id"]; ?>" contenteditable><?php echo $row["address"]; ?></td>
<td class="phoneNumber" data-id2="<?php echo $row["id"]; ?>" contenteditable><?php echo $row["phoneNumber"]; ?></td>
<td class="appointmentTime" data-id2="<?php echo $row["id"]; ?>" contenteditable><?php echo $row["appointmentTime"]; ?></td>
<td class="appointmentDate" data-id2="<?php echo $row["id"]; ?>" contenteditable><?php $row["appointmentDate"]; ?></td>
<td class="message" data-id2="<?php echo $row["id"]; ?>" contenteditable><?php echo $row["message"]; ?></td>
<td><button type="button" name="delete_btn" data-id3="<?php echo $row["id"]; ?>" class="btn btn-xs btn-danger btn_delete">Delete</button></td>
<td align="center"><input type="checkbox" name="<?php echo $checked_id[]; ?>" class="checkbox" value="<?php echo $row["id"]; ?>"</td>
</tr>
}
试试这个:
res.status(206);