상품후기에 포토후기만 추출하려고합니다.

상품후기에 포토후기만 추출하려고합니다.

QA

상품후기에 포토후기만 추출하려고합니다.

본문

상품후기작성시 에디터로만 사진업로드가 가능하게되있어서

에디터로 올린 이미지만 따로 추출하여 포토후기 란을 만들려고 하는데

아래와같이 작성해서 작업을 하면 에디터로 올린 이미지는 나오는데 에디터로 올린 이미지가 없을경우

공란으로 나와서 10개를 추출한다고 하면 그중에 10개중 이미지가 없는개 7개이면 실제로 3개만 추출되고 있습니다..

 

첨부파일이 있을경우 'and wr_file > 0' 이걸 추가하면 되는걸로 알고있는데 에디터로만 올린 이미지일 경우 잘안되네요

<div class="pic_lt">
  
    <ul>
    <?php
    $sql = "select * from ".$g5[g5_shop_item_use_table]." where is_confirm = 1 and is_content ='".$row[imgs]."'  order by is_id desc limit 40 "; 
    $result = sql_query($sql) or die(sql_error()); 
    for($i=0 ; $row=sql_fetch_array($result); $i++) 
    { 
     
  
        $it_href = G5_SHOP_URL."/item.php?it_id=".$row['it_id'].""; 
        $is_content = get_view_thumbnail(conv_content($row['is_content'], 1), 100, 100); 
        $content = get_itemuselist_thumbnail($row['it_id'], $row['is_content'], 100, 100);
$pattern = "/<img.*?src=[\"']?(?P<url>[^(http)].*?)[\"' >]/i";

preg_match($pattern,stripslashes(str_replace('&','&',$is_content)), $matches);

$imgs = substr($matches['url'],1);

    ?>
        <li>
            <img src="<?php echo $imgs; ?>">
           

            <span class="lt_date">.</span>
        </li>
    <?php }  ?>
    <?php if (count($list) == 0) { //게시물이 없을 때  ?>
  
    <?php }  ?>
    </ul>
   

</div>
 

이 질문에 댓글 쓰기 :

답변 2

query 문에서 이미지 추출이 안되므로,

php로 이미지를 추출한 부분에서 

if 문으로 이미지가 있음 경우에만 출력하면 될듯 하네요.

query 문에 limit 은 삭제하고,

추출한 수를 카운트해서 원하는 개수가 되면 break; 하면 됩니다.

limit를 삭제하니깐 페이지 로딩이 너무 길어지네요 추출한수 카운트를해서 break;..말은이해가 가는데 아직 짜집기만 하는 수준이라 엄두가 안나네요 예제라도 알수있을까요


<div class="pic_lt">
<ul>
<?php
$no=0;
$sql = "select * from ".$g5[g5_shop_item_use_table]." where is_confirm = 1 and is_content ='".$row[imgs]."' order by is_id desc limit 100 ";
$result = sql_query($sql) or die(sql_error());
for($i=0 ; $row=sql_fetch_array($result); $i++)
{
$it_href = G5_SHOP_URL."/item.php?it_id=".$row['it_id']."";
$is_content = get_view_thumbnail(conv_content($row['is_content'], 1), 100, 100);
$content = get_itemuselist_thumbnail($row['it_id'], $row['is_content'], 100, 100);
$pattern = "/<img.*?src=[\"']?(?P<url>[^(http)].*?)[\"' >]/i";
 
preg_match($pattern,stripslashes(str_replace('&','&',$is_content)), $matches);
 
$imgs = substr($matches['url'],1);
if($imgs) {
$no++;
?>
<li>
<img src="<?php echo $imgs; ?>">
 
<span class="lt_date">.</span>
</li>
<?php
if($no==40) break;
}
?>
<?php } ?>
<?php if (count($list) == 0) { //게시물이 없을 때 ?>
<?php } ?>
</ul>
</div>

<div class="pic_lt">
 
    <ul>
      <?php
    $no=0;
    $sql = "select * from ".$g5[g5_shop_item_use_table]." where is_confirm = 1  order by is_id desc limit 50 ";
    $result = sql_query($sql) or die(sql_error());
    for($i=0 ;  $row=sql_fetch_array($result); $i++)
    {
   
 
        $it_href = G5_SHOP_URL."/item.php?it_id=".$row['it_id']."";
        $is_content = get_view_thumbnail(conv_content($row['is_content'], 1), 200, 200);
        $content = get_itemuselist_thumbnail($row['it_id'], $row['is_content'], 100, 100);
       
$pattern = "/<img.*?src=[\"']?(?P<url>[^(http)].*?)[\"' >]/i";

        preg_match($pattern,stripslashes(str_replace('&','&',$is_content)), $matches);

        $imgs = substr($matches['url'],1);

if($imgs) {
$no++;
?>
 
        <li><img src="<?php echo $imgs; ?>">
            <span class="lt_date"></span>
        </li>
<?php
  if($no==3) break;
}
?>
    </ul>
 
<?php } ?>
<?php if (count($list) == 0) { //게시물이 없을 때 ?>
<?php } ?>

</div>

답변감사드립니다~~^^

개수조절은 되는데 limit 수가 늘어나면 로딩이 길어지는건 그대로입니다.

후기가 300건이내에 포토상품평이 한개도 없을경우 limit300이상을 걸거나 제한을 없애야하는데

그렇게 되면 로딩이길어서 ..사용하기가 어렵습니다. 계속 문의드리기가 죄송스러워 포토후기는

차후에 적용해봐야겠어요

그래도 어려운질문에 친절히 답변해주셔서 감사드립니다 !!!^^

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

회원로그인

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