안녕하세요. :)
에스코피에님이 올리신 장바구니 기능을 list.skin.php에서 사용하려고 하는데요.
이런 사이트처럼 만들려고 하는데, 이상하게 제일 하단에 있는 게시물만 장바구니 담기가 됩니다.
list.skin.php 에서 장바구니 기능을 사용하려면 어떻게해야 되나요?
<form name="fcart" method="get">
<input type=hidden name="sell_price" value="<?=$view[sel_price]?>">
<input type=hidden name="wr_id" value="<?=$list[$i][wr_id]?>">
<input type=hidden name="bo_table" value="<?=$bo_table?>">
<input type=hidden name="sell_price" value="<?=$view[sel_price]?>">
<input type=hidden name="wr_id" value="<?=$list[$i][wr_id]?>">
<input type=hidden name="bo_table" value="<?=$bo_table?>">
<? echo "<a href=\"javascript:cart_add();\">[장바구니]</a>";?>
<script language="JavaScript">
function cart_add()
{
var f = document.fcart;
f.action = "<?=$g4['path']?>/cart/cart.php?bo_table=<?=$bo_table?>&wr_id=<?=$list[$i][wr_id]?>";
f.submit();
function cart_add()
{
var f = document.fcart;
f.action = "<?=$g4['path']?>/cart/cart.php?bo_table=<?=$bo_table?>&wr_id=<?=$list[$i][wr_id]?>";
f.submit();
}
</script>
</script>
</form>
답변 3개 / 댓글 2개
채택된 답변
+20 포인트
2013-12-27 (금) 19:35:54
php소스에서 확인을 하지 마시고요
페이지 소스보기에서 소스를 확인하시기 바랍니다.
간단하게 예를 드리면
<input type=text name="aa" value="1">
<input type=text name="aa" value="2">
<input type=text name="aa" value="3">
이런식으로 값을 넘겨보면 항상 3이 넘어가게 되죠
왜냐하면 같은 name값은 제일 하단값이 넘어가게 되어있기 때문입니다.
그래서 처리하는 방법은 aa[]로 넘기거나 자바스크립트에서 name이 aa인것을 모두 찾아 value값에
, 나 |로 연결해서 다른 name값으로 넘기는 방법을 사용하죠
제가 말씀드린것은 저런식으로 구성이 되어있는지 확인을 해보시라는 것입니다. ^^
그럼 수고하세요~~
답변에 대한 댓글 1개
2013-12-28 (토) 01:17:26
2018-04-13 (금) 15:29:05
많은 도움이 되었습니다. 감사합니다.
2013-12-27 (금) 01:56:43
name 값을 체크해보세요
마지막것만 들어간다면 여러개가 동일이름으로 되어있을때 발생하는 문제입니다.
답변에 대한 댓글 1개
2013-12-27 (금) 10:34:37
글루님 name 값이 뭔지 잘 모르겠어요.ㅜㅜ
아래는 장바구니 lib 파일인데, 이곳에서 동일이름을 발생하는 요소가 있는지
봐주실 수 있으신가요?
<?
if (!defined('_GNUBOARD_')) exit;
function shop_price($cart,$bo_table)
{
global $g4;
$price = 0;
if(is_array($cart))
{
foreach($cart as $wr_id => $qty)
{
$tmp_write_table = $g4['write_prefix'] . $bo_table;
$sql = "select * from $tmp_write_table where wr_id=$wr_id";
$row = sql_fetch($sql);
$price +=$row[sel_price]*$qty;
}
}
return $price;
}
function shop_qty($cart)
{
$items = 0;
if(is_array($cart))
{
foreach($cart as $isbn => $qty)
{
$items += $qty;
}
}
return $items;
}
?>
아래는 장바구니 lib 파일인데, 이곳에서 동일이름을 발생하는 요소가 있는지
봐주실 수 있으신가요?
<?
if (!defined('_GNUBOARD_')) exit;
function shop_price($cart,$bo_table)
{
global $g4;
$price = 0;
if(is_array($cart))
{
foreach($cart as $wr_id => $qty)
{
$tmp_write_table = $g4['write_prefix'] . $bo_table;
$sql = "select * from $tmp_write_table where wr_id=$wr_id";
$row = sql_fetch($sql);
$price +=$row[sel_price]*$qty;
}
}
return $price;
}
function shop_qty($cart)
{
$items = 0;
if(is_array($cart))
{
foreach($cart as $isbn => $qty)
{
$items += $qty;
}
}
return $items;
}
?>
답변을 작성하려면 로그인이 필요합니다.
<a href="<?=$g4[path]?>/cart/cart.php?bo_table=oneroom&wr_id=<?=$list[$i][wr_id]?>">찜하기</a>
wr_id 값에 array가 계속 나왔었는데, echo 밖으로 나오니, 해결 되었습니다.
많은 도움이 되었습니다.
정말 감사 드립니다. ㅎ
좋은 주말 되세요. :)