[seesion 찜게시판 문의] 가장 최근것을 위에 오게 하려면 어떻게해야 될까요? 채택완료
안녕하세요. :)
아래는 찜게시판 소스입니다.
리스트 정렬시 가장 최근것이 밑으로 붙는데요.
가장 최근것을 위에 오게 하려면 어떻게해야 될까요?
도움 부탁 드려요.
function shop_price($today,$bo_table) { global $g4;
$price = 0; if(is_array($today)) {
foreach($today 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; }
$tmp_write_table = $g4['write_prefix'] . $bo_table;
// if($amount){ $item_qt = $amount; } else{ $item_qt = 1; }
if($wr_id && $bo_table) {
$wr = get_write($tmp_write_table, $wr_id); if (!$wr[wr_id]) alert("존재하지 않는상품입니다.\\n\\n삭제된상품이거나 판매보류된 상품입니다.");
if(!isset($_SESSION[$today])) { $_SESSION[$today] = array(); $_SESSION['items'] = 0; $_SESSION['total_price'] = 0;
}
if(isset($_SESSION[$today][$wr_id])){ $_SESSION[$today][$wr_id]++;
} else { $_SESSION[$today][$wr_id] = $item_qt;
}
$_SESSION['total_price'] = shop_price($_SESSION[$today],$bo_table); $_SESSION['items'] = shop_qty($_SESSION[$today]); }
if(isset($_POST['save'])) { foreach ($_SESSION[$today] as $wr_id => $qty) { if($_POST[$wr_id]=='0') unset($_SESSION[$today][$wr_id]); else $_SESSION[$today][$wr_id] = $_POST[$wr_id]; } $_SESSION['total_price'] = shop_price($_SESSION[$today],$bo_table); $_SESSION['items'] = shop_qty($_SESSION[$today]); }
if($del) { unset($_SESSION[$today][$del]); }
if($wr_id || $del) { goto_url("./today.php"); }
$colspan = 4;
if($state_path =='today.php')$colspan++;
?>
if($_SESSION[$today]&&array_count_values($_SESSION[$today]))
{
foreach ($_SESSION[$today] as $wr_id => $qty)
{
$tmp_write_table = $g4['write_prefix'] . $bo_table;
$sql = "select * from $tmp_write_table where wr_id='$wr_id'";
$list = sql_fetch($sql);
$t = 0; // 첫번째 이미지
$row = sql_fetch(" select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$t' ");
if($row[bf_file]){
$i_width = "120";
$dst = "$g4[path]/data/file/$bo_table/thumbs/" . $row[bf_file];
$dst_img = "";
}
$del = "
";
?>
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인
세션값을 저장할때면,
if(isset($_POST['save']))
{
foreach ($_SESSION[$today] as $wr_id => $qty)
{
if($_POST[$wr_id]=='0')
unset($_SESSION[$today][$wr_id]);
else
$_SESSION[$today][$wr_id] = $_POST[$wr_id];
}
$_SESSION['total_price'] = shop_price($_SESSION[$today],$bo_table);
$_SESSION['items'] = shop_qty($_SESSION[$today]);
}
이 부분을 수정해야 되나요?
에고~ 어렵네요. ㅜㅜ
어떻게 수정해야 되는지 알려주실 수 있으신가요?
도움 부탁 드려요~