我有产品名称并想选择下载路径。据它说,我得到一个错误
警告:mysql_num_rows() 期望参数 1 是资源,布尔值在...
好像没有这样的入口。
<?php
$keyarray=array('num_cart_items'=>2, 'item_name2'=>'5', 'item_name1'=>'6' );
$itemname='';
for ($i=1; $i<= $keyarray['num_cart_items'] ;$i++){
$itemname[]= $keyarray['item_name'.$i];};
foreach($itemname as & $var){
echo $var;
$sql = mysql_query("SELECT * FROM products WHERE product_name='$var' ");
$productCount = mysql_num_rows($sql); // count the output amount
$checkout_path ="";
if ($productCount > 0) {
// get path
$row = mysql_fetch_array($sql);
$path = $row["path"];
$checkout_path[]=array('path'=>$path);
echo $checkout_path;
}
}
//echo $checkout_path;
?>