어렵네요 좀 알려주세요.. 필드를 0과 1값을 받아 0값만 불러올수 있는 방법은? > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

어렵네요 좀 알려주세요.. 필드를 0과 1값을 받아 0값만 불러올수 있는 방법은? 정보

어렵네요 좀 알려주세요.. 필드를 0과 1값을 받아 0값만 불러올수 있는 방법은?

본문

아래의 소스를 설명을 드리자면 goods라는 테이블에서 등록된 상품을 리스트페이지에 불러드리는 소스입니다.
테이블 필드에는 idx ,g_code, g_name, g_price 등등이 있습니다.

예를 들어 goods 테이블에 choice라는 필드를 추가로 만들어서 0 과 1만 선택하여 만약에 goods테이블에서 choice의 필드값이 0인 값만 불러들일려면 어떻게 하나요?

그리고 goods테이블에서 초이스값이 1인 값만 불러들일수 있는 방법은?

아래의 소스를 토대로 알려주시면 감사하겠습니다.

그럼 부탁드립니다. 




<?
$sub_code = '2';
include("./_common.php");
include("$g4[path]/_head.php");


$shop = get_shop();
$goods_dir = $g4[path]."/data/goods/";

if(!$Type || $Type == ""){$Type = "1";}


if($CODE!="")
{
$category_info = get_category($CODE);
if($category_info[c_depth] == "0")
{
$sub_cate_sql = "select * from g4_category where c_pcode = '".$CODE."'";
$sub_cate_rst = mysql_query($sub_cate_sql);
$tmp_cate = array();
while($sub_cate = mysql_fetch_array($sub_cate_rst))
{
$tmp_cate[] = $sub_cate[c_code];
}

if(count($tmp_cate))
{
$join_cate = implode("|",$tmp_cate);
$cate_where = " and c_code REGEXP '".$join_cate."' ";
}
else
{
$cate_where = " and c_code='".$CODE."' ";
}
}
else
{
$cate_where = " and c_code='".$CODE."' ";
}
}

if($search_str!="")
{
$search_where = " and concat(g_name,g_info,g_create,g_nation,g_content) like '%".$search_str."%' ";
}


$goods_sql = "select g_code from g4_goods where 1 ".$cate_where.$search_where;

if (!$sst){$sst  = "idx";$sod = "desc";}

$goods_sql.= " order by $sst $sod ";

$total_count = mysql_num_rows(mysql_query($goods_sql));

switch($Type)
{
case "1":{$rows = 15;break;}
case "2":{$rows = 16;break;}
case "3":{$rows = 1;break;}
default:{$rows = 10;}
}

$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if ($page == "") { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함

$goods_sql.=" limit $from_record, $rows";
$goods_rst = mysql_query($goods_sql);

$pagelist = get_paging("5", $page, $total_page, "$_SERVER[PHP_SELF]?CODE=$CODE&Type=$Type&search_str=$search_str$qstr&page=");

if(!$pagelist || $pagelist==""){$pagelist = "1";}
?>
<link rel="stylesheet" href="<?=$g4['path']?>/shop/style.css" type="text/css">
<script language="javascript" src="<?=$g4['path']?>/shop/shop.js"></script>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr height="25">
<td><?include("goods_list_head.php");?></td>
</tr>
<!--상품 리스트상단부분 줄시작<tr><td height="1" bgcolor="#D7D7D7"></td></tr>상품 리스트상단부분 줄끝-->
<tr>
<td>

<table cellpadding="0" cellspacing="0" width="980">
<tr>
<td width="980">
<?
while($goods_row = mysql_fetch_array($goods_rst))
{
$goods = get_goods($goods_row[g_code]);
include("goods_list.".$Type.".skin.php");
}
if($total_count == "0"){echo("<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100' style='border-bottom:solid 1px #D7D7D7'><tr><td align='center'>등록된 상품이 없습니다.</td></tr></table>");}
?>
</td>
</tr>
</table>
</td>
</tr>
<?if($Type=="2"){?><tr><td height="1" bgcolor="#D7D7D7"></td></tr><?}?>
<tr height="120">
<td align="center"><?=$pagelist?></td>
</tr>
</table>
<?
include("$g4[path]/_tail.php");
?>

댓글 전체

전체 66,558 |RSS
그누4 질문답변 내용 검색

회원로그인

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