영카트4로 만들어진 쇼핑몰에 상품마다 관련 상품을 등록하는 것은 아무래도 비능률적인 일인 것 같아서 약간의
꼼수를 부려서 같은 카테고리내 상품 중에서 상품코드 번호를 기준으로 전 후로 몇개의 상품이 출력되도록 수정을
해봤다. it_opt1 이라는 필드에 상품코드를 입력했기 때문에 이것을 기준으로 정렬이 되도록 수정을 했다.
항상 그렇지만 코드는 완전 지저분하다. 특정 상품 전 후로 상품 코드를 불러서 정렬을 해야하기 때문에 sql 쿼리를
두번 시도해야하는데.. 이거 한번에 할 수 있으면 좋겠는데.. ㅋ 그래서 union 명령을 이용해서 다른 두 개의 쿼리
결과값을 하나로 합친 후 이것을 내림차순을 정렬해서 출력이 되도록 했다. 영카트4의 기분 기능을 이용하기 때문에
적용에 크게 문제는 없을 것이라 생각이 된다. itemp.php 파일을 수정하면 된다. 제대로 한 건지 모르겠다. ^^;
꼼수를 부려서 같은 카테고리내 상품 중에서 상품코드 번호를 기준으로 전 후로 몇개의 상품이 출력되도록 수정을
해봤다. it_opt1 이라는 필드에 상품코드를 입력했기 때문에 이것을 기준으로 정렬이 되도록 수정을 했다.
<!-- 관련상품 출력(JAG몰 추가) -->
<tr>
<td height="100" valign="top">
<?
$sql_1 = " select * from $g4[yc4_item_table] where it_opt1 < '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 desc ";
$sql_2 = " select * from $g4[yc4_item_table] where it_opt1 > '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 asc ";
$result_1 = sql_query($sql_1);
$num_1 = @mysql_num_rows($result_1);
$result_2 = sql_query($sql_2);
$num_2 = @mysql_num_rows($result_2);
if($num_1 < 6) $num_2 = 12 - $num_1;
if($num_2 < 6) $num_1 = 12 - $num_2;
if($num_1 >= 6 && $num_2 >= 6) $num_1 = $num_2 = 6;
$sql = " ( select * from $g4[yc4_item_table] where it_opt1 < '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 desc limit $num_1 ) union ( select * from $g4[yc4_item_table] where it_opt1 > '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 asc limit $num_2 ) order by it_opt1 desc ";
$list_mod = $default[de_rel_list_mod];
$img_width = $default[de_rel_img_width];
$img_height = $default[de_rel_img_height];
$td_width = (int)(100 / $list_mod);
$result = sql_query($sql);
$num = @mysql_num_rows($result);
if ($num)
include "$g4[shop_path]/maintype10.inc.php";
else
echo "이 상품과 관련된 상품이 없습니다.";
?>
</td>
</tr>
<tr>
<td height="100" valign="top">
<?
$sql_1 = " select * from $g4[yc4_item_table] where it_opt1 < '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 desc ";
$sql_2 = " select * from $g4[yc4_item_table] where it_opt1 > '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 asc ";
$result_1 = sql_query($sql_1);
$num_1 = @mysql_num_rows($result_1);
$result_2 = sql_query($sql_2);
$num_2 = @mysql_num_rows($result_2);
if($num_1 < 6) $num_2 = 12 - $num_1;
if($num_2 < 6) $num_1 = 12 - $num_2;
if($num_1 >= 6 && $num_2 >= 6) $num_1 = $num_2 = 6;
$sql = " ( select * from $g4[yc4_item_table] where it_opt1 < '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 desc limit $num_1 ) union ( select * from $g4[yc4_item_table] where it_opt1 > '$it[it_opt1]' and ca_id = '$ca_id' and it_use = '1' order by it_opt1 asc limit $num_2 ) order by it_opt1 desc ";
$list_mod = $default[de_rel_list_mod];
$img_width = $default[de_rel_img_width];
$img_height = $default[de_rel_img_height];
$td_width = (int)(100 / $list_mod);
$result = sql_query($sql);
$num = @mysql_num_rows($result);
if ($num)
include "$g4[shop_path]/maintype10.inc.php";
else
echo "이 상품과 관련된 상품이 없습니다.";
?>
</td>
</tr>
항상 그렇지만 코드는 완전 지저분하다. 특정 상품 전 후로 상품 코드를 불러서 정렬을 해야하기 때문에 sql 쿼리를
두번 시도해야하는데.. 이거 한번에 할 수 있으면 좋겠는데.. ㅋ 그래서 union 명령을 이용해서 다른 두 개의 쿼리
결과값을 하나로 합친 후 이것을 내림차순을 정렬해서 출력이 되도록 했다. 영카트4의 기분 기능을 이용하기 때문에
적용에 크게 문제는 없을 것이라 생각이 된다. itemp.php 파일을 수정하면 된다. 제대로 한 건지 모르겠다. ^^;
'작업물 정리 > 프로그래밍' 카테고리의 다른 글
| 영카트4 고객용 영수증 출력 페이지 (0) | 2009/08/25 |
|---|---|
| 영카트4 상품상세 페이지 관련 상품 출력 (0) | 2009/07/29 |
| 그누보드 회원정보를 검색해서 해당 주소 업체 출력하는 페이지 (0) | 2008/01/29 |
| 업무관리용 그누보드 게시판 최종 작업 버전 (4) | 2008/01/14 |
| 아직 더 해야하는건가? 그누보드 프로젝트 게시판 (4) | 2008/01/08 |
| 진행중인 전체 프로젝트 출력 페이지 (0) | 2008/01/05 |
| 그누보드 프로젝트 기록 게시판 스킨 (0) | 2008/01/04 |
| 업무관리용 그누보드 게시판 스킨 (0) | 2007/12/31 |
| 개인 업무일정 관리용 그누보드 스킨 (0) | 2007/12/14 |
| 윈도우에서 프로젝트 관리툴 Trac 설치와 기타 Plugin 설치 (0) | 2007/12/06 |





댓글을 달아 주세요