상품 이미지 필드를 추가하려고 하는데요

상품 이미지 필드를 추가하려고 하는데요

QA

상품 이미지 필드를 추가하려고 하는데요

본문

it_img1부터 it_img10까지 되어있는데 it_img11를 추가해서 적용해보니 오류나네요 ㅠㅠ

어떻게하면 이미지 필드를 추가할수 있을까요?

도움 부탁드립니다.

이 질문에 댓글 쓰기 :

답변 4

어떤 오류가 발생하는지 알려주셔야 정확한 답변이 가능합니다.

추가적으로 필드를 추가하실 때는 코드 상에서 추가된 필드에 대한 코드를 추가해주셔야 하고
다음으로 phpmyadmin 등을 이용해 해당 테이블에 필드를 추가해주셔야만 합니다.
adm/shop_admin



<section id="anc_sitfrm_img">


    <h2 class="h2_frm">이미지</h2>

    <?php echo $pg_anchor; ?>




    <div class="tbl_frm01 tbl_wrap">

        <table>

        <caption>이미지 업로드</caption>

        <colgroup>

            <col class="grid_4">

            <col>

        </colgroup>

        <tbody>

        <?php for($i=1; $i<=12; $i++) { ?>

        <tr>

            <th scope="row"><label for="it_img1">이미지 <?php echo $i; ?></label></th>

            <td>

                <input type="file" name="it_img<?php echo $i; ?>" id="it_img<?php echo $i; ?>">

                <?php

                $it_img = G5_DATA_PATH.'/item/'.$it['it_img'.$i];

                if(is_file($it_img) && $it['it_img'.$i]) {

                    $size = @getimagesize($it_img);

                    $thumb = get_it_thumbnail($it['it_img'.$i], 25, 25);

                ?>

                <label for="it_img<?php echo $i; ?>_del"><span class="sound_only">이미지 <?php echo $i; ?> </span>파일삭제</label>

                <input type="checkbox" name="it_img<?php echo $i; ?>_del" id="it_img<?php echo $i; ?>_del" value="1">

                <span class="sit_wimg_limg<?php echo $i; ?>"><?php echo $thumb; ?></span>

                <div id="limg<?php echo $i; ?>" class="banner_or_img">

                    <img src="<?php echo G5_DATA_URL; ?>/item/<?php echo $it['it_img'.$i]; ?>" alt="" width="<?php echo $size[0]; ?>" height="<?php echo $size[1]; ?>">

                    <button type="button" class="sit_wimg_close">닫기</button>

                </div>

                <script>

                $('<button type="button" id="it_limg<?php echo $i; ?>_view" class="btn_frmline sit_wimg_view">이미지<?php echo $i; ?> 확인</button>').appendTo('.sit_wimg_limg<?php echo $i; ?>');

                </script>

                <?php } ?>

            </td>

        </tr>

        <?php } ?>

        </tbody>

        </table>

    </div>

</section>




>


lib/shop.lib.php




// 상품 이미지를 얻는다

function get_it_image($it_id, $width, $height=0, $anchor=false, $img_id='', $img_alt='')

{

    global $g5;




    if(!$it_id || !$width)

        return '';




    $sql = " select it_id, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10, it_img11, it_img12

	 from {$g5['g5_shop_item_table']} where it_id = '$it_id' ";

    $row = sql_fetch($sql);




    if(!$row['it_id'])

        return '';




    for($i=1;$i<=12; $i++) {

        $file = G5_DATA_PATH.'/item/'.$row['it_img'.$i];

        if(is_file($file) && $row['it_img'.$i]) {

            $size = @getimagesize($file);

            if($size[2] < 1 || $size[2] > 3)

                continue;




            $filename = basename($file);

            $filepath = dirname($file);

            $img_width = $size[0];

            $img_height = $size[1];




            break;

        }

    }









// 이미지 URL 을 얻는다.

function get_it_imageurl($it_id)

{

    global $g5;




    $sql = " select it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10, it_img11, it_img12

                from {$g5['g5_shop_item_table']}

                where it_id = '$it_id' ";

    $row = sql_fetch($sql);

    $filepath = '';




    for($i=1; $i<=12; $i++) {

        $img = $row['it_img'.$i];

        $file = G5_DATA_PATH.'/item/'.$img;

        if(!is_file($file))

            continue;




        $size = @getimagesize($file);

        if($size[2] < 1 || $size[2] > 3)

            continue;




        $filepath = $file;

    }




    if($filepath)

        $str = str_replace(G5_PATH, G5_URL, $filepath);

    else

        $str = G5_SHOP_URL.'/img/no_image.gif';




    return $str;

}






moblie/shop/largeimage.php







$sql = " select it_id, it_name, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10, it_img11, it_img12

            from {$g5['g5_shop_item_table']} where it_id='$it_id' ";

$row = sql_fetch_array(sql_query($sql));




if(!$row['it_id'])

    alert_close('상품정보가 존재하지 않습니다.');




$imagefile = G5_DATA_PATH.'/item/'.$row['it_img'.$no];

$imagefileurl = G5_DATA_URL.'/item/'.$row['it_img'.$no];

$size = getimagesize($imagefile);




$g5['title'] = "{$row['it_name']} ($it_id)";

include_once(G5_PATH.'/head.sub.php');

?>




<div id="sit_pvi_nw" class="new_win">

    <h1 id="win_title">상품 이미지 새 창 보기</h1>




    <div id="sit_pvi_nwbig">

        <?php

        $thumbnails = array();

        for($i=1; $i<=12; $i++) {

            if(!$row['it_img'.$i])

                continue;




            $file = G5_DATA_PATH.'/item/'.$row['it_img'.$i];

            if(is_file($file)) {

                // 썸네일

                $thumb = get_it_thumbnail($row['it_img'.$i], 60, 60);

                $thumbnails[$i] = $thumb;

                $imageurl = G5_DATA_URL.'/item/'.$row['it_img'.$i];

        ?>

        <span>

            <a href="javascript:window.close();">

                <img src="<?php echo $imageurl; ?>" width="<?php echo $size[0]; ?>" height="<?php echo $size[1]; ?>" alt="<?php echo $row['it_name']; ?>" id="largeimage">

            </a>

        </span>

        <?php

            }

        }

        ?>

    </div>






이렇게 적용햇는데요

select it_id, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10, it_img11, it_img12 from g5_shop_item where it_id = '1392285222'

1054 : Unknown column 'it_img12' in 'field list'

error file : /k3/shop/item.php

라고 오류뜹니다.




넵 감사합니다. it_img12 필드를 추가 생성했습니다. 오류사라졌지만 이미지 출력 안되네요..

다운로드66.png
 


답변을 작성하시기 전에 로그인 해주세요.
전체 4

회원로그인

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