[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 = "<img src='{$dst}' width='120' height='80' border='0'>";
}
$del = "<a href=\"javascript:today_del('./today.php?bo_table=$bo_table&del=$wr_id);\"><img src='./img/del.gif' onmouseover=\"this.src='./img/del_on.gif'\"
onmousedown=\"this.src='./img/del_on.gif'\"
onmouseout=\"this.src='./img/del.gif'\" alt=\"삭제\"
type=\"image\" align=\"absmiddle\" border=0></a>";
?>
답변 1
if($_SESSION[$today]&&array_count_values($_SESSION[$today])) {
foreach ($_SESSION[$today] as $wr_id => $qty) {
....