채택완료

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

2014-02-14 (금) 12:47:53 6,742
it_img1부터 it_img10까지 되어있는데 it_img11를 추가해서 적용해보니 오류나네요 ㅠㅠ

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

도움 부탁드립니다.

|

답변 4개 / 댓글 2개

채택된 답변
+20 포인트
어떤 오류가 발생하는지 알려주셔야 정확한 답변이 가능합니다.

추가적으로 필드를 추가하실 때는 코드 상에서 추가된 필드에 대한 코드를 추가해주셔야 하고
다음으로 phpmyadmin 등을 이용해 해당 테이블에 필드를 추가해주셔야만 합니다.
와우~! 이미지 출력잘되네요..

바쁘신 업무에도 불구하고 답변주심에 다시 한번 감사를 드립니다.

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

다운로드66.png
 


답변에 대한 댓글 1개

이미지 업로드가 제대로 되지 않은 경우인 것 같습니다. itemformupdate.php 파일에서 이미지
업로드 처리 부분을 수정해보시기 바랍니다.
adm/shop_admin

Copy
<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

Copy
// 상품 이미지를 얻는다
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

Copy
$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

라고 오류뜹니다.




답변에 대한 댓글 1개

it_img12 필드가 g5_shop_item 테이블에 존재하지 않는 오류입니다.
phpmyadmin 등을 이용해 item 테이블에 it_img12 필드를 추가 생성해 주셔야 합니다.

답변을 작성하려면 로그인이 필요합니다.