상품 리스트출력에 where 절 추가하려면

상품 리스트출력에 where 절 추가하려면

QA

상품 리스트출력에 where 절 추가하려면

본문

프론트 화면의 상품출력시에 여분필드의 값과 같은 값만 출력하려고

상품출력소스를 찾는데 아무리봐도 잘 못찾겠습니다.

 

아이템출력관련해서 어디서 찾을 수 있을까요?

 

어드민이나 다른 쪽에서는 적용이안되고 꼭 프론트 상품출력시에만 조건문을 걸고자합니다 .

아시는분있으시면 꼭 부탁드립니다. ^^ 

이 질문에 댓글 쓰기 :

답변 2

<?php

$list = new item_list();

$list->set_type(1); // 스킨파일과 썸네일 크기등 나머지와 동일하게 셋팅하기 위함

$list->set_query("select * from `{$g5['g5_shop_item_table']}` where it_use = '1'  and it_1='1'  order by it_order, it_id desc limit 10");

echo $list->run();

?>

이런식으로 하면 될듯합니다.
나머지 set_view 옵션은 다른 항목들 참조하시구요.

답변정말 감사합니다. 그런데 알려주신 내용은 일반적인 상황에서 list.php 에서 작성하면 list스킨에서 그대로 적용되는 것인데요, 제가 list 스킨을 커스트마이징해서    if ($this->view_it_id) { 문을 걷어내고 사용중에 있습니다. 아래 소스를 보시면 아시겠지만, list10.skin.php 에서 조건문을 넣어주면 좋겠는데, 아무리해도 안되네요. list.php 윗단에 shop.lib.php 나 어딘가에 쿼리문이 분명있을텐데 왜 못찾겠는지...ㅠ

제 답변은 사실 프론트라고 하셔서 shop/index.php 여기를 상정해서 단 답변이었습니다.
list.php도 마찬가지긴 합니다. 요는 set_query()라는 메서드였죠. 조건을 추가하려는등 임의로 sql문을 바꾸려면 이걸 사용하시면 됩니다.
스킨에서는 이미 디비에서 데이터를 가져온 후에 출력만 담당하는 부분이라 조건을 추가하려면 결국 list.php 파일을 수정하셔야 할겁니다.
기본 sql문은 말씀하신대로 shop.lib.php 에 있습니다만 그걸 수정하시면 원치않는 결과를 보실수도..

set_query()로 sql문을 새로 지정하면 카테고리가 무시되니 그 부분도 넣어줘야겠네요.
list.php 에서 echo $list->run(); 이 문장을 찾아 바로 위에 추가해주세요.
다른 부분은 가급적 그냥 두심이 좋겠습니다.


        $where = '';
        if ($ca['ca_id']) {
            $where = " ca_id like '{$ca['ca_id']}%' or ca_id2 like '{$ca['ca_id']}%' or ca_id3 like '{$ca['ca_id']}%' ";
        }
        $where .= ($where?' and ':'') . ' it_1="1" '; // 추가 조건문
        $sql = " select * from `{$g5['g5_shop_item_table']}` " . ($where?' where '.$where:'') . ' order by $order_by limit $from_record, ".($ca['ca_list_mod'] * $ca['ca_list_row']);
        $list->set_query($sql);

<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_CSS_URL.'/style.css">', 0);
 
?>
<script type="text/javascript"> 
$(document).ready( 
function() { 
$.each($('.tr_arr:odd'), function(i){ // 홀수 번째 
$(this).css("backgroundColor", "#F7F7F7"); 
}); 
$.each($('.tr_arr:even'), function(i){ //짝수 번째 
$(this).css("backgroundColor", "#FFFFFF"); 
}); 
}); 
 
$(function(){
 $('.forRowspan').each(function() {
  var table = this;
  $.each([1] , function(c, v) {
   var tds = $('>tbody>tr>td:nth-child(' + v + ')', table).toArray(), i = 0, j = 0;
   for(j = 1; j < tds.length; j ++) {
    if(tds[i].innerHTML != tds[j].innerHTML) {
     $(tds[i]).attr('rowspan', j - i);
     i = j;
     continue;
    }
    $(tds[j]).hide();
   }
   j --;
   if(tds[i].innerHTML == tds[j].innerHTML) {
    $(tds[i]).attr('rowspan', j - i + 1);
   }
  });
 });
});
</script> 

  
<div style="width: 1000px;  border-top: 0px solid #DEDEDE; border-bottom: 2px solid #DEDEDE;">
  <table  cellpadding="0" cellspacing="1" border="0" style="width:1000px; background-color:#CCC" class="forRowspan">
  
    <?php for ($i=0; $row=sql_fetch_array($result); $i++) { 
 
    // 상품품절체크
  $is_soldout = is_soldout($row['it_id']);
  // 주문가능체크
  $is_orderable = true;
    if(!$row['it_use'] || $row['it_tel_inq'] || $is_soldout)
        $is_orderable = false;
  
   ?>
 
 
<a href=""></a>
     <tr class="tr_arr"> 
   
            <td width="350px" style="padding:4px 10px; line-height:180%" onClick="window.open('<?php echo G5_SHOP_URL; ?>/item_popup.php?it_id=<?php echo $row['it_id'] ?>','mailform','width=600, height=520, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');">  
<span style="font-size:14px"><? echo $row['it_name'] ?></span>   <img src = "../img/course/info_kangja.jpg" align="absmiddle">
<br />
<span style="color:#666; font-size:14px">
     <?php if($row['it_basic'])
  {
   echo conv_content($row['it_basic'], $html); 
  }  
   ?>
</span>
</td>

 <td width="200px" style="padding:4px 10px">
        
          
        
        
        <span style="font-size:13px">
  <? 
  $time = strtotime($row['it_5']);
  $data_print=date("a g:i ",$time);
  echo $data_print; ?>~<? 
  $time2 = strtotime($row['it_6']);
        $data_print2=date("g:i ",$time2);
  echo $data_print2; ?></span>  
        
        
        
        </td>
  <td width="420px" style="padding:4px 10px">
        <span style="font-size:13px">            
  <?php 
        $sql2 = "select * from `teacher` where `it_id` = '{$row['it_id']}'";
  $result2 = sql_query($sql2, false);
         for ($i=0; $row2=sql_fetch_array($result2); $i++) { 
  ?> 
   <b><?php echo $row2['wr_session']; ?></b> <?php echo $row2['wr_teacher']; ?>  
  <? } ?>     
        </span></td>
  <td width="100px" style="padding:4px 10px" align="center">
       <?php  if($row['it_11'] == '신청'){ ?>
        <a href="<?php echo G5_SHOP_URL; ?>/item.php?it_id=<?php echo $row['it_id'] ?>" class="sct_a"><img src = "../img/bbs/btn_B.gif" align="absmiddle"></a>
  <?php } elseif($row['it_11'] == '임박'){ ?>    
        <a href="<?php echo G5_SHOP_URL; ?>/item.php?it_id=<?php echo $row['it_id'] ?>" class="sct_a"><img src = "../img/bbs/btn_ending.gif" align="absmiddle"></a>
        <?php } elseif($row['it_11'] == '마감'){ ?>    
        <img src = "../img/bbs/btn_end.gif" align="absmiddle">
        <?php } elseif($row['it_11'] == '대기중'){ ?>    
        <a href="#" onClick="window.open('../formmail/form_reservation.html','mailform','width=580, height=520, toolbar=no, menubar=no, scrollbars=no, resizable=yes');return false;"><img src = "../img/bbs/btn_k2.gif" align="absmiddle"></a>        
     <?php } ?>    
        </td>
 </tr>
  
    
<? } ?>
    </table>

</div> 
 

답변을 작성하시기 전에 로그인 해주세요.
전체 24
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT