如何在选择查询中使用循环?查询一次只能从 Select Query 中获取一行。我想在选择查询中获取多行但通过循环
选择身份证
$id=$_REQUEST['id'];
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[] = $row1['id'];
$k++;
}
return $results1;
}
PID 数组
$pid1=get_id($id);
<?php
$max1=count($pid1);
for($n=0; $n<$max1; $n++)
{?>
<input type="hidden" name="pid[]" value="<?php echo $pid1[$n]?>" />
<?php }?>
PID 会话
$_SESSION['pid']=$_POST['pid'];
我想要fetch
选择查询中的多行但通过循环
<?php
$pid = join(',',$_SESSION['pid']);
$result=mysql_query("SELECT id AS wid FROM mywishlist
where pid='$pid'")
or die("Id Problem"."<br/><br/>".mysql_error());
$results= array();
$i=0; // add the new line
while($row=mysql_fetch_array($result)){
$results[$i] = $row['wid'];
$i++;
}
echo $results;
$max=count($results);
for($j=0; $j<$max; $j++)
{
?>
<input type="text" name="wid[]" value="<?php echo $results[$j]; ?>" />
<?php }?>