数组从这个表单中获得(Select Boxes)。数组到字符串的转换错误php sql
<?php session_start();?>
<?php require("Connections/Project.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
$sql_s="SELECT * FROM t_dvd_copy";
$query_s=mysql_query($sql_s);
?>
<body>
<?php
$sql="SELECT *, dvd_title FROM t_dvd_copy INNER JOIN t_dvd ORDER BY dvd_title ASC";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)) {
?>
<form action="calculatepage.php" method="post">
<table width="200" border="1">
<tr>
<td><?php echo $row['dvd_copy_id']?></td>
<td><?php echo $row['dvd_title']?></td>
<td><?php echo $row['price']?></td>
<td><input type="checkbox" value="<?php echo $row['dvd_copy_id']?>" name="checkbox[]"></td>
</tr>
</table>
<p>
<?php
}
?>
<input type="submit" name="button" id="button" value="Submit" />
</form>
</p>
</body>
</html>
我想使用从形式得到了阵列来显示它在SQL表,其中ID(s)为从表单/阵列(calculatepage.php)
<?php include("Connections/Project.php");?>
<?php session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Calculate</title>
</head>
<body>
<table>
<tr>
<?php
$ide=$_POST['checkbox'];
$sql="select * from t_dvd_copy where dvd_copy_id='$ide'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
echo $row['dvd_copy_id'];
}
?>
</body>
</html>
我错误消息“注意:数组到字符串转换在C:\ xampp \ htdocs \ pro \ calculatepage.php在第17行”
我先用foreach和print_r测试它。它确实显示数字值。
我该如何解决这个问题?
'$ ide'是一个数组,你不能简单地将它插入到一个字符串中。 – deceze
您的表单传递的复选框变量是一个数组;你不能在SQL语句中插入那个无用的信息 – WillardSolutions
你能给我一些建议吗? – Escii