【发布时间】:2018-01-12 13:29:46
【问题描述】:
我想在 php.ini 表格的每一行中添加一个复选框。 如何在 PHP 中通过 CheckBox 用 Yes 或 No 填充数据库单元格? 当我更改复选框名称(例如“名称”)时,出现错误。
<?php
$con=mysql_connect("localhost","biterium_login","login");
mysql_select_db("biterium_login");
// Check connection
if (!$con){
die("به دلیل مشکل زیر، اتصال برقرار نشد : <br />" . mysql_error());
}
$result = mysql_query("SELECT * FROM member",$con);
echo "<table border='1'>
<tr>
<th>id</th>
<th>name</th>
<th>phone</th>
<th>email</th>
<th>action</th>
<th>action</th>
<th>active</th>
</tr>";
while($row = mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['phone']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td><a href='delete.php?id=".$row['id']."'>Delete</a></td>";
echo "<td><a href='FormUpdate.php?id=".$row['id']."'>Edit</a></td>";
echo "<td><input type='checkbox' value='".$row['id']."' name='".$row['id']."'></td>";
echo "</tr>";
}
echo "</table>";
?>
<a href='add.html'>ADD</a></td>
【问题讨论】:
-
仅供参考,you shouldn't use
mysql_*functions in new code。它们不再维护and are officially deprecated。看到red box?改为了解prepared statements,并使用PDO 或MySQLi - this article 将帮助您决定哪一个最适合您。 -
set name="checkArray[]" 当您提交表单时,您将使用 $_REQUEST 获得选中的复选框值
-
$_Get语法不正确。查找“php superglobal”以获得正确的语法。
标签: php mysql database checkbox insert