채택완료

장바구니 내에서 위시리스트 넣기

질문 그대로 장바구니 페이지에서 제가원하는 품목을 위시리스트에 넣고싶은데.... 음.....

wishupdate에서 if(is_array($it_id))이쪽에서 안 되는거같은데... 제품 번호까지 다 날아갔는데 왜 상품 목록에서 사라져보이죠?ㅜㅜ 고수님들..ㅠㅠ

wishupdate.php

Copy
<?php?>if (!$is_member)    alert('회원 전용 서비스 입니다.', G5_BBS_URL.'/login.php?url='.urlencode($url));if ($w == "d"){    $wi_id = trim($_GET['wi_id']);    $sql = " select mb_id from {$g5['g5_shop_wish_table']} where wi_id = '$wi_id' ";    $row = sql_fetch($sql);    if($row['mb_id'] != $member['mb_id'])        alert('위시리시트 상품을 삭제할 권한이 없습니다.');    $sql = " delete from {$g5['g5_shop_wish_table']}              where wi_id = '$wi_id'                and mb_id = '{$member['mb_id']}' ";    sql_query($sql);}else{     if(is_array($it_id))        $it_id = $_POST['it_id'][0];    if(!$it_id)        alert('상품코드가 올바르지 않습니다.', G5_SHOP_URL);    // 상품정보 체크    $sql = " select it_id from {$g5['g5_shop_item_table']} where it_id = '$it_id' ";    $row = sql_fetch($sql);    if(!$row['it_id'])        alert('상품정보가 존재하지 않습니다.', G5_SHOP_URL);    $sql = " select wi_id from {$g5['g5_shop_wish_table']}              where mb_id = '{$member['mb_id']}' and it_id = '$it_id' ";    $row = sql_fetch($sql);    if (!$row['wi_id']) { // 없다면 등록        $sql = " insert {$g5['g5_shop_wish_table']}                    set mb_id = '{$member['mb_id']}',                        it_id = '$it_id',                        wi_time = '".G5_TIME_YMDHIS."',                        wi_ip = '$REMOTE_ADDR' ";        sql_query($sql);    }}goto_url('./wishlist.php');?>​

cart.php

Copy
<a href="javascript:item_wish(document.frmcartlist, '<?php echo $row['it_id']; ?>');" ><img src="<?php echo G5_IMG_URL;?>/zim.jpg" /></a>
Copy
<script>        </script>        function item_wish(f, it_id)        {            f.url.value = "<?php echo G5_SHOP_URL; ?>/wishupdate.php?it_id="+it_id;            f.action = "<?php echo G5_SHOP_URL; ?>/wishupdate.php";            f.submit();   alert(f.url.value);        }               </script>​

답변 1개 / 댓글 5개

채택된 답변
+20 포인트

print_r($it_id)); //값이 있는지 먼저 확인하시고


if(is_array($it_id)) //이게 배열인지를 묻는건데 배열이 아닐텐데....  

  $it_id = $_POST['it_id'][0]; //배열이면 다중을 처리해야 하는데 하나만 하네요...

else

  $it_id = $_POST['it_id']; 

추가해서 테스트를 해보시지요.. 

답변에 대한 댓글 5개

추가해서 해보았는데 한개만 올라가고 더이상올라가질 않아요 it_id값은 날아가는데 그다음 위시리스트 추가가 안되네요..ㅠㅠㅠㅠ
영카트는 사용을 안해봐서 잘 모르겠으나
위 소스는 하나만 처리하도록 되어 있습니다. 배열값으로 되어 있으면 while문으로 처리를 해야 합니다.
아... 음....;;;
if(is_array($it_id))
$it_id = $_POST['it_id'][0];
else
$it_id = $_POST['it_id'];
if(!$it_id)
alert('상품코드가 올바르지 않습니다.', G5_SHOP_URL);

//위기능 필요없음.

if(count($it_id) < 1)
alert('상품코드가 올바르지 않습니다.', G5_SHOP_URL);

for ($i=0; $i<count($it_id); $i++) //갯수만큼 루프
{
$nit_id = $it_id[$i];

// 상품정보 체크
$sql = " select it_id from {$g5['g5_shop_item_table']} where it_id = '$nit_id' ";
$row = sql_fetch($sql);
if(!$row['it_id'])
alert('상품정보가 존재하지 않습니다.', G5_SHOP_URL);
$sql = " select wi_id from {$g5['g5_shop_wish_table']}
where mb_id = '{$member['mb_id']}' and it_id = '$nit_id' ";
$row = sql_fetch($sql);
if (!$row['wi_id']) { // 없다면 등록
$sql = " insert {$g5['g5_shop_wish_table']}
set mb_id = '{$member['mb_id']}',
it_id = '$nit_id',
wi_time = '".G5_TIME_YMDHIS."',
wi_ip = '$REMOTE_ADDR' ";
sql_query($sql);
}
}

이렇게 한번 해보세요
우와!!!!!!!!!!!!!!!!!감사합니다.ㅠㅠㅠㅠㅠ 아직까지 헤메고있었는데.ㅠㅠㅠ

답변을 작성하려면 로그인이 필요합니다.