상품개수를 표시하는 방법없을까요?
본문
<?
//echo $g4[yc4_item_table]."<BR>";
$str = "";
$exists = false;
$depth2_ca_id = substr($ca_id, 0, 2);
/*$row = sql_fetch($sql);
$cnt = $row['cnt'];*/
$sql = " select ca_id, ca_name from $g4[yc4_category_table]
where ca_id like '${depth2_ca_id}%'
and length(ca_id) = 4
and ca_use = '1'
order by ca_id ";
$result = sql_query($sql);
$co = 0;
$num_rows = 6; // 한줄에 보일 이미지 수
$width_per = (int)(100 / $num_rows);
while ($row=sql_fetch_array($result)) {
$item_rows = sql_fetch("select * from $g4[yc4_item_table] where (ca_id like '{$row[ca_id]}%' or ca_id2 like '{$row[ca_id]}%' or ca_id3 like '{$row[ca_id]}%') and it_use = '1' ");
//if($item_rows[it_id]){
$co++;
$mod_co = $co%$num_rows;
if($mod_co == "1") $str .= "<tr>";
$str .= "<td width='$width_per%' height='35' align='center' onclick=\"javascript:list_submit('$row[ca_id]')\" style='border:#CCCCCC 1px solid; cursor:hand;' onmouseover=this.style.backgroundColor='#df5e64' onmouseout=this.style.backgroundColor=''>";
// 재고 it_stock_qty = 0 >> 품절.
// 품절까지 뽑은거
/*$row_count = 0; // 전체 재고 - 품절 수치
$row2 = sql_fetch(" select count(*) as cnt from $g4[yc4_item_table] where (ca_id like '$row[ca_id2]%' or ca_id2 like '$row[ca_id]%' or ca_id3 like '$row[ca_id2]%') and it_use = '1' " );
// 품절인놈만 뽑은거
$row3 = sql_fetch(" select count(*) as cnt from $g4[yc4_item_table] where (ca_id like '$row[ca_id2]%' or ca_id2 like '$row[ca_id]%' or ca_id3 like '$row[ca_id2]%') and it_use = '1' and it_stock_qty = 0 " );
//if(empty($row2[cnt]) !==FALSE && empty($row3[cnt] !==FALSE ){*/
/*$row_count = $row2[cnt] - $row3[cnt];*/
if ($item_rows == "0") {
$styles = "background:#e9e9e9; color:#afafaf;";
} else {
$styles = "";
}
$str .= "<table cellpadding='0' cellspacing='0' width='100%' border=0 height='35' ><tr><td align='center' style='{$styles}'>";
$str .= "<a href='./list.php?ca_id=$row[ca_id]' style='display:block; width:100%; height:35px; line-height:35px; {$styles}'>$row[ca_name] </a>";
$exists = true;
$str .= "</td></tr></table>";
$str .= "</td>";
if($mod_co == "0") {
}
//}
}
while($mod_co > 0) {
$co++;
$mod_co = $co%$num_rows;
if($mod_co == "1") $str .= "<tr>";
$str .= "<td width='$width_per%' align='center'> </td>";
if($mod_co == "0") $str .= "</tr>";
}
if ($exists) {
echo "$str";
}
?>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
<?
list.php 파일인데 $row_count = $row2[cnt] - $row3[cnt]; 이 식대로 계산을 하면, 품절상품 제외한채, 상품개수가
상품명 (21) 이렇게 뜨긴하는데,
$row2 = sql_fetch(" select count(*) as cnt from $g4[yc4_item_table] where (ca_id like '$row[ca_id2]%' or ca_id2 like '$row[ca_id]%' or ca_id3 like '$row[ca_id2]%') and it_use = '1' " );
이렇게 하면 페이지 로딩속도가 현저히 느려집니다.
이 방법말고 다른 방법으로 갯수가 뜨는 방법이 있을까요.