我需要帮助来解决选择查询 where IN 子句?
1)现在的问题是选择查询不起作用where pid IN ($pid)
?
2)第二个问题是CCID input text
空的?
当我echo $pid=implode ($new_product).'<br>';
显示PID
哪些创建为 $_SESSION['pid']..!
使用时出错 ($pid)
CCID Problem
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ')' at line 1
创建会话 Pid 的页面
session_start();
$_SESSION['pid1'][]=$_POST['pid'];
function get_id($id){
$result1=mysql_query("select * from products where id='$id'")
or die("Id Problem"."<br/><br/>".mysql_error());
$results1= array();
$k=0; // add the new line
while($row1=mysql_fetch_assoc($result1)){
$results1[$k] =$row1['id'];
$k++;
}
return $results1;
}
$pid1=get_id($id);
<form method="post">
<input type="hidden" name="pid[]" value="<?php echo $pid1?>" />
</form>
Page2.php
session_start();
if(is_array($_SESSION['pid1'])){
$max=count($_SESSION['pid1']);
for($i=0; $i<$max; $i++){
$new_product=$_SESSION['pid1'][$i];
echo $pid=implode ($new_product).'<br>';
}}
$result=mysql_query("SELECT id AS ccid FROM cart where pid IN ($pid) ")
or die("CCID Problem"."<br/><br/>".mysql_error());
while($row=mysql_fetch_array($result)){
?>
<input type="text" name="ccid[]" value="<?php echo $row['ccid'];?>" />
<?php }?>