我有一个大约 5 小时的问题...我可以在合并之前从一个数组中打印一个 mysql 选择到一个表...我的代码是:在 Cookies 中有这个数组 Array( [] => [1254] => 325 [2112] => 77 [354] => 2 ) 其中 [1254 是产品的鳕鱼] => 325 是定量的
<table width="100%" border="0" cellpadding="3" cellspacing="2">
<tr><!--prepare row of head cols html static-->
<td> COD</td>
<td> PROD</td>
<td>CAT</td>
<td>**CANT**</td>
</tr>
<?php
////array in cookie to variable php $rr
$rr = $_COOKIE['coo'];
foreach ($rr as &$arr){////for each element of $rr generate one register
$SQL="SELECT cod_pro,name,cod_cat,('$arr') AS quant FROM products
WHERE cod_pro=".$arr."
ORDER BY cod_cat asc";
$result=mysql_query($SQL,$lnk) ;
if (mysql_num_rows($result)>0){ //if exist anyone
while($registers=mysql_fetch_array($result,MYSQL_ASSOC)){
////print each row here all right
echo "<tr><td>".$registers["cod_pro"]."</td>"."<td>".$registers["name"]."/td>"
."<td>".$registers["cod_cat"]."/td><td>".$registers["quant"]."</td></tr>";
////$registers["quant"] i want add one col with this value from cookie
?>
<?php }?>
<?php }
} ?>
</table>
问题是 $registers["cant"] 我如何执行 SELECT my sql,以提供此输出;[] => [1254] => 325 [2112] => 77 [354] => 2
COD (pk) NAME COD_CAT **quant** This i can´t show
--------------------------------------------
1254 Car (bd) 1 (bd) **325**
2112 Cicles(bd) 2 (bd) **77**
354 toys (in bd) 3 (bd) **2**
任何想法谢谢