PHP 프로그래밍

본문 바로가기
사이트 내 전체검색


Web Programming >> PHP Programming
[목차]
제26장 쇼핑몰 만들기 3 - 이벤트 경매

    1. 경매관리 (관리자)

 

경매에는 여러 가지 유형이 있다. 회원이면 아무나 경매 제품을 올릴 수 있는 "자유 경매", 무조건 1000원부터 시작하는 "1000원 경매", 쇼핑몰이나 기타 포탈 사이트에서 이벤트 형태로 진행하는 "이벤트 경매"등 경매의 운영방식의 차이에 따라 각종 경매 유형들이 있고 앞으로도 계속해서 만들어질 것이다.

다음에서는 쇼핑몰에서 유용하게 활용할 수 있는 이벤트 경매를 소개한다. 이벤트 경매는 관리자가 경매 중개인으로써의 자격을 가지고, 경매 제품을  의뢰 받거나 또는 자신이 경매 제품을 올려 입찰하는 형태를 말한다. 그러므로, 쇼핑몰에 판매중인 제품을 창고 정리와 같은 형태로 경매에 내놓는 경우도 여기에 속한다.

 

필요한 프로그램들 다음과 같다.

/ --  shop/ -- admin/ --- auction/ --(경매관리-> 추가되는 부분)

             |         |            |

             |         |            +-- list.html

             |         |            +-- postform.html

             |         |            +-- post.html

             |         |            +-- prod_list.html

             |         |            +-- modifyform.html

             |         |            +-- modify.html

             |         |            +-- deleteform.html

             |         |            +-- delete.html

             |         +- menu.html (관리자 메뉴 수정)

             +-- menu.html (쇼핑몰 메뉴 수정)

 

1. 경매 테이블 만들기

경매 제품에 대한 목록이 저장될 auction 테이블

 

CREATE TABLE auction (
uid int(11) NOT NULL auto_increment,
prod_uid int(11) NOT NULL,
stprice double,
stdate varchar(30),
enddate varchar(30),
bidstat int(2),
winner varchar(20),
dealstat int(2),
etc text,
register varchar(20),
PRIMARY KEY (uid)
);

 

입찰자들의 목록이 저장될 테이블

CREATE TABLE bid (
uid int(11) NOT NULL auto_increment,
auction_uid int(11) NOT NULL,
user_id varchar(20),
myprice double,
signdate varchar(30),
PRIMARY KEY (uid)
);

 

2. 메뉴 추가하기(관리자)

파일명 : menu.hrml

<?

include "../user_function.html";

include "../dbconn.html";

 

include("admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

?>

<HTML>

<HEAD>

<TITLE> 관리자 - 메뉴 </TITLE>

</HEAD>

 

<BODY BGCOLOR="#EEEEEE">

<br>

<UL>

    <LI> <A HREF="product/list.html" target="bookshop-detail">제품관리</A>

    <LI> <A HREF="order/" target="bookshop-detail">주문관리</A><p>

    <LI> <A HREF="auction/list.html" target="bookshop-detail">경매관리</A><p>

    <LI> <A HREF="member/list.html" target="bookshop-detail">회원관리</A><p>

    <li><a href="logout.html" target="_top">종료</a>

</ul>

</BODY>

</HTML>

 

 

 

3. 경매제품 목록보기(관리자)

파일명 : list.hrml

<?

/*

유닉스 타임을 대입하면 2000-08-10 10:20:30 와 같은 방식으로 값을 리턴하는 사용자정의 함수 ymdhis()를 정의한다.

*/

function ymdhis($t){

return date("Y-m-d H:i:s",$t);

}

$nowdate=ymdhis(time());

 

/*

mkunixtime()은 2000-08-10 10:20:30 와 같은 방식으로 되어 있는 일자 값을 분석하여 유닉스 타임으로 시각값을 리턴하는 사용자정의 함수이다.

mkunixtime($ymdhis,0,0,0,0,2,0)->2일

*/

function mkunixtime($ymdhis,$ha,$ia,$sa,$ma,$da,$ya){

$ymdhisa=explode(" ",$ymdhis);

$ymda=explode("-",$ymdhisa[0]);

$hisa=explode(":",$ymdhisa[1]);

$y=$ymda[0];

$m=$ymda[1];

$d=$ymda[2];

$h=$hisa[0];

$i=$hisa[1];

$s=$hisa[2];

return mktime($h+$ha,$i+$ia,$s+$sa,$m+$ma,$d+$da,$y+$ya);

}

?>

<?

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

?>

 

<?

if(!$db) $db = "auction";

 

########### 한 페이지당 출력할 게시물의 수

$num_per_page = 5;

 

########### 게시물 출력목록 하단에 링크를 걸 페이지의 개수

$page_per_block = 5;

 

########### 페이지 초기화

if(!$page) {

     $page = 1;

}

 

 

$query = "SELECT uid,prod_uid,stprice,stdate,enddate,bidstat,winner,dealstat,register FROM $db ";

if($keyword) $query .= " where $type like '%$keyword%'";

$query .= " ORDER BY enddate";

 

$result = mysql_query($query,$dbconn);

if(!$result) {

   $errNO = mysql_errno($dbconn);

   $errMSG = mysql_error($dbconn);

       

   echo("에러코드 $errNO : $errMSG<br>");

   exit;

}

 

$total_record = mysql_num_rows($result);

 

########## 전체 페이지수를 계산한다. ##########

$total_page = ceil($total_record/$num_per_page);

 

########## 현재의 페이지에서 출력할 게시물의 범위를 결정한다. ##########

if(!$total_record) {

   $first = 1;

   $last = 0;   

} else {

   $first = $num_per_page*($page-1);

   $last = $num_per_page*$page;

 

   $last -= 1;

   if($total_page == $page) {

      $last = $total_record - 1;

   }

}

?>

 

<HTML>

<HEAD>

<TITLE>경매관리 </TITLE>

</HEAD>

<style type="text/css">

//<!--

A:hover {  text-decoration: underline;  color: #CC0000; font-size: 9pt}

a:link {  text-decoration: none}

a:visited {  text-decoration: none}

td {  font-size: 9pt; font-family: "굴림"}

.retextwite { font-family: "굴림"; font-size: 9pt; color: #FFFFFF; text-decoration: none ; line-height: 12pt }

.text { font-family: "굴림"; font-size: 9pt; text-decoration: none ; color: #000000}

 

//-->

</style>

<script language="JavaScript">

<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}

//-->

</script>

<body>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr align="center">

    <td>  <br>

      <table width="308" border="0" cellspacing="0" cellpadding="0" height="25">

                          <tr align="center" valign="middle">

                            

          <td ><font size=4>경매 등록 정보</font></td>

                          </tr>

                        </table>

                               <form action="list.html" method="post" name="search">

        <table border="0" align="center" cellpadding="0" cellspacing="0">

          <tr>

            <td class="text" bgcolor="#EEEEEE">

              <table border="0" width="100%" cellpadding="0" cellspacing="0">

                <tr valign="bottom">

                  <td class="text">

                    <input type="button" name="Submit56" value="경매등록" onClick="self.location='postform.html?page=<?echo("$page");?>'">

                  </td>

                  <td class="text" align="right">

                    <select name="keyfield">

                      <option value="prodname" >제품명</option>

                      <option value="sortcode">분류코드</option>

                      <option value="stdate">경매시작일자</option>

                      <option value="myprice">가격</option>

                    </select>

                    <input type="text" size="20" maxlength="30" name="key">

                    <input type="submit" value="Search" name="submit">

                  </td>

                </tr>

              </table>

                 

              <table cellpadding="2" width="100%" cellspacing="1">

                <tr class="retextwite">

                  <td align="center" bgcolor="#6666FF" >번 호</td>

                  <td align="center" bgcolor="#6666FF" >상 태</td>

                  <td align="center" bgcolor="#6666FF" >제품명</td>

                  <td align="center" bgcolor="#6666FF" >등록자</td>

                  <td align="center" bgcolor="#6666FF" >경매시작</td>

                </tr>

                <tr class="retextwite">

                  <td align="center" bgcolor="#6666FF" >번 호</td>

                  <td align="center" bgcolor="#6666FF" >마감직전</td>

                  <td align="center" bgcolor="#6666FF" >분류</td>

                  <td align="center" bgcolor="#6666FF" >최종가격</td>

                  <td align="center" bgcolor="#6666FF" >경매종료</td>

                </tr>

<?

$article_num = $total_record - $num_per_page*($page-1);

 

########## 테이블내 모든 레코드의 각 데이터 값을 각각의 변수에 저장하여 출력한다.

for($i = $first; $i <= $last; $i++) {

        $uid = mysql_result($result,$i,0);

        $prod_uid = mysql_result($result,$i,1);

        $stprice = mysql_result($result,$i,2);

        $stdate = mysql_result($result,$i,3);

        $enddate = mysql_result($result,$i,4);

        $bidstat = mysql_result($result,$i,5);

        $winner = mysql_result($result,$i,6);

        $dealstat = mysql_result($result,$i,7);

        $register = mysql_result($result,$i,8);

 

   $query1="SELECT name,part FROM product WHERE uid=$prod_uid ";

   $result1 = mysql_query($query1);

   if (!$result1) {

       error("QUERY_ERROR");

       exit;

   }

   $prod_name = mysql_result($result1,0,0);   

   $prod_part = mysql_result($result1,0,1);   

 

   $query1="SELECT myprice FROM bid WHERE auction_uid=$uid ";

   $result1 = mysql_query($query1);

   if (!$result1) {

       error("QUERY_ERROR");

       exit;

   }

   $bid_total = mysql_num_rows($result1);   

        if($bid_total) $last_price = mysql_result($result1,0,0);   

 

        if($article_num % 2) $color = "#FFFFFF";

        else $color = "#ECECFF";

?>

                <tr>

                  <td class="text" align="center" bgcolor="<?echo("$color");?>" >

                                        <?echo("$article_num");?>

                                  </td>

                  <td align="center" bgcolor="<?echo("$color");?>"> <?echo("$deal_stat");?> (입찰수:<?echo("$bid_total");?>)</td>

                  <td bgcolor="<?echo("$color");?>" align="center"> <b><?echo("$prod_name");?></b></td>

                  <td align="center" bgcolor="<?echo("$color");?>"><a href="mailto:owl@owl.co.kr" class="text">

                    <?echo("$register");?></a><span class="text"></span></td>

                  <td align="center" bgcolor="<?echo("$color");?>"><?echo("$stdate");?>부터</td>

                </tr>

                <tr>

                  <td class="text" align="center" bgcolor="<?echo("$color");?>" ><a href="modifyform.html?auc_uid=<?echo("$uid");?>&page=<?echo("$page");?>">수정</a>

                    <a href="deleteform.html?number=<?echo("$uid");?>&page=<?echo("$page");?>">삭제</a>

                  </td>

                  <td align="center" bgcolor="<?echo("$color");?>"> <font color="#FF3333">

 <?if ($bidstat==1){ ?>마감

                    <?

$deadlineall = mkunixtime($enddate,0,0,0,0,0,0) - mkunixtime($nowdate,0,0,0,0,0,0);

$deadlines = ($deadlineall % 60);

$deadlinei = intval($deadlineall / 60);

if ($deadlinei>=60) $deadlineh = intval($deadlinei / 60); $deadlinei = $deadlinei % 60;

 

if ($deadlineh>0)echo $deadlineh."시간 ";

if ($deadlineh>0 || $deadlinei>0)echo $deadlinei."분 ";

echo $deadlines."초";

?> 전<?}?></font> </td>

                  <td bgcolor="<?echo("$color");?>" align=center> <a href="list.html?page=<?echo("$page");?>" class="text"><?echo("$prod_part");?></a></td>

                  <td align="center" bgcolor="<?echo("$color");?>"><span class="text">&nbsp<?echo("$last_price");?></span></td>

                  <td align="center" bgcolor="<?echo("$color");?>"><?echo("$enddate");?>까지</td>

                </tr>

<?

$article_num --;

}

?>

              </table>

<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">

<tr>

   <td colspan="6" align="center">

<?

### 게시물 목록 하단의 각 페이지로 직접 이동할 수 있는

### 페이지링크에 대한 설정을 한다.

$total_block = ceil($total_page/$page_per_block);

$block = ceil($page/$page_per_block);

 

$first_page = ($block-1)*$page_per_block;

$last_page = $block*$page_per_block;

 

if($total_block <= $block) {

   $last_page = $total_page;

}

 

########## 이전페이지블록에 대한 페이지 링크 ##########

if($block > 1) {

   $my_page = $first_page;

   echo("<font size=2><a href=\"$php_self?page=$my_page\" >

   [이전 ${page_per_block}개]</a></font>");

}

 

### 현재의 페이지 블럭범위내에서 각 페이지로 바로

### 이동할 수 있는 하이퍼링크를 출력한다.

for($direct_page = $first_page+1; $direct_page <= $last_page; $direct_page++) {

   if($page == $direct_page) {

      echo("<font size=2><b>[$direct_page]</b></font>");

   } else {

      echo("<font size=2><a href=\"list.html?page=$direct_page\">

      [$direct_page]</a></font>");

   }

}

 

########## 다음페이지블록에 대한 페이지 링크 ##########

if($block < $total_block) {

   $my_page = $last_page+1;

   echo("<font size=2><a href=\"list.html?page=$my_page\">

   [다음 ${page_per_block}개]</a></font>");

}

?>   

   </td>

</tr>

</table>                              

            <table width="100%" border="0" cellspacing="0" cellpadding="0">

                <tr>

                  <td><FONT SIZE=2>

        [ <?

        $ppage = $page + 1;

        $npage = $page - 1;

 

        if($page > 1) echo "<A HREF='list.html?page=$ppage'>이전페이지</A>";

        else echo "이전페이지";

        echo "]&nbsp;&nbsp;[ ";

        if($page < $total_page) echo "<A HREF='list.html?db=$db&page=$npage'>다음페이지</A>";

        else echo "다음페이지";

        ?>] </td>

                  <td align="right">[<?echo $total_record;?> records / <?echo $total_page;?>

                    pages]<br>

                    현재시각 : <?echo $nowdate;?> </td>

                </tr>

              </table>

            </td>

                          </tr>

                        </table>

</form>

                        

           </td>

  </tr>

</table>

</body>

</html>

 

4. 경매제품 등록하기(관리자)

파일명 : postform.hrml

 <?

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

 

if($number) {

   $query1="SELECT uid,name,part,info FROM product WHERE uid=$number ";

   $result1 = mysql_query($query1);

   if (!$result1) {

       error("QUERY_ERROR");

       exit;

   }

        $total_record = mysql_num_rows($result1);

        if($total_record) {

           $prod_uid = mysql_result($result1,0,0);   

           $prod_name = mysql_result($result1,0,1);   

           $prod_part = mysql_result($result1,0,2);   

           $prod_info = mysql_result($result1,0,3);   

         }

 

}

?>

<HTML>

<HEAD>

<TITLE> 경매제품 등록 </TITLE>

<style type="text/css">

//<!--

A:hover {  text-decoration: underline;  color: #CC0000; font-size: 9pt}

a:link {  text-decoration: none}

a:visited {  text-decoration: none}

td {  font-size: 9pt; font-family: "굴림"}

.retextwite { font-family: "굴림"; font-size: 9pt; color: #FFFFFF; text-decoration: none ; line-height: 12pt }

.text { font-family: "굴림"; font-size: 9pt; text-decoration: none ; color: #000000}

 

//-->

</style>

 

</HEAD>

<body bgcolor="#EEEEEE">

 <b></b>

<table width="100%" border="0" cellspacing="0" cellpadding="0" >

  <tr align="center">

    <td>  <br>

      <table width="308" border="0" cellspacing="0" cellpadding="0" height="25" >

                          <tr align="center" valign="middle">

          <td><font size=4">아울쇼핑센터 경매 등록 정보</font></td>

                          </tr>

                        </table>

    

      <form method="post" action="post.html"  name="upform">

        <script>

function checkformin(){

var theform;

theform=document.upform;

 

if (theform.prod_uid.value==""){

window.alert("제품을 선택해 주세요.");

theform.prod_uid.focus();

return false;

} else if (theform.stprice.value==""){

window.alert("시작가격을 입력해 주세요.");

theform.stprice.focus();

return false;

}else if (theform.stprice.value < 0 || theform.period.value < 0){

window.alert("가격과 기간은 음수일 수 없습니다.");

theform.stprice.focus();

return false;

}else if (theform.period.value==""){

window.alert("경매기간을 입력해 주세요.");

theform.period.focus();

return false;

}else{

theform.submit();

}

return false;

}

</script>

        <table width="500" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td bgcolor="#EEEEEE">

              <input type="button" name="Submit332" value="제품가져오기" onClick="self.location='prod_list.html'">

            </td>

          </tr>

        </table>

        <table width="500" border="0" cellspacing="0" cellpadding="2" bgcolor="#6666FF">

          <tr valign="top">

            <td colspan="2">

              <table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#6666FF">

                <tr>

                  <td width="50" class="retextwite">분류코드</td>

                  <td width="437" bgcolor="#6666FF">

                    <input type="TEXT" name="prod_uid"  readonly  value="<?echo("$prod_part");?>">

                  </td>

                </tr>

              </table>

              

            </td>

          </tr>

          <tr valign="top">

            <td width="250"  bgcolor="#FFFFFF" align="center">

              <table width="100%" border="0" cellspacing="0" cellpadding="2">

                <tr>

                  <td width="81" bgcolor="#FFFFFF">제품명</td>

                  <td width="161" bgcolor="#FFFFFF">

                    <input type="TEXT" name="prod_name"  readonly  value="<?echo("$prod_name");?>">

                  </td>

                </tr>

                <tr>

                  <td width="81" bgcolor="#FFFFFF">제품코드</td>

                  <td width="161" bgcolor="#FFFFFF">

                    <input type="TEXT" name="prod_uid"  readonly  value="<?echo("$prod_uid");?>">

                  </td>

                </tr>

                <tr bgcolor="#ECECFF">

                  <td width="81">시작가격</td>

                  <td width="161">

                    <input type="TEXT" name="stprice" value="1000">

                  </td>

                </tr>

                <tr bgcolor="#FFFFFF">

                  <td>경매시작일자</td>

                  <td>

                    <input type="TEXT" name="stdate" value="<?echo date("Y-m-d H:i:s");?>">

                    <br>

                    # 예)2001-12-30 14:20:50</td>

                </tr>

                <tr bgcolor="#ECECFF">

                  <td width="81">경매기간</td>

                  <td width="161">

                    <input type="TEXT" name="period" value="7" size="5">

                    일간 </td>

                </tr>

              </table>

              

              

            </td>

            <td width="250" align="right" valign="top" bgcolor="#ECECFF"> 제품요약정보<br>

              <textarea name="prod_info" cols="30"  readonly  rows="7"><?echo("$prod_info");?></textarea>

              <br>

              <br>

              경매정보<br>

              <textarea name="etc" cols="30" rows="7"></textarea>

            </td>

          </tr>

        </table>

        <input type="button" name="Submit4" value="경매등록"  onclick="checkformin()">

        <input type="button" name="Submit53" value="경매목록" onClick="self.location='list.html?page=<?echo("$page");?>'">

      </form>

        </td>

  </tr>

</table>

</body>

</html>

 

 

파일명 : post.hrml

 <?

/*

유닉스 타임을 대입하면 2000-08-10 10:20:30 와 같은 방식으로 값을 리턴하는 사용자정의 함수 ymdhis()를 정의한다.

*/

function ymdhis($t){

return date("Y-m-d H:i:s",$t);

}

$nowdate=ymdhis(time());

 

/*

mkunixtime()은 2000-08-10 10:20:30 와 같은 방식으로 되어 있는 일자 값을 분석하여 유닉스 타임으로 시각값을 리턴하는 사용자정의 함수이다.

mkunixtime($ymdhis,0,0,0,0,2,0)->2일

*/

function mkunixtime($ymdhis,$ha,$ia,$sa,$ma,$da,$ya){

$ymdhisa=explode(" ",$ymdhis);

$ymda=explode("-",$ymdhisa[0]);

$hisa=explode(":",$ymdhisa[1]);

$y=$ymda[0];

$m=$ymda[1];

$d=$ymda[2];

$h=$hisa[0];

$i=$hisa[1];

$s=$hisa[2];

return mktime($h+$ha,$i+$ia,$s+$sa,$m+$ma,$d+$da,$y+$ya);

}

 

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

 

if($prod_uid) {

        $enddate=ymdhis(mkunixtime($stdate,0,0,0,0,$period,0));

 

        $query1 = "insert into auction  (prod_uid,stprice,stdate,enddate,etc,register) VALUES ($prod_uid,'$stprice','$stdate','$enddate','$etc','$user_id')";

 

        $result1 = mysql_query($query1);

        if (!$result1) {

                error("QUERY_ERROR");

                exit;

        }

        echo ("<meta http-equiv='Refresh' content='0; URL=./list.html?page=$page'>");

}

else {

        echo ("<meta http-equiv='Refresh' content='0; URL=./postform.html?page=$page'>");

}

?>

 

파일명 : prod_list.hrml

경매제품 등록시 제품목록에서 제품정보를 가져올 수 있게 하였습니다.

<?

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

?>

 

<html>

 

<head>

<title>경매관리-제품목록</title>

</head>

   <style type="text/css">

   <!--

   a:link,a:visited,a:active {

      text-decoration : none; font-size: 10pt;

   }

   a:hover {

      text-decoration : underline; font-size: 10pt;

      color : red;

   }

   //-->

   </style>

 

<body bgColor="#FFFFFF">

<?

if(!$page) {

   $page = 1;

}

 

$num_per_page = 10;

$page_per_block = 10;

 

########## 파일이 저장될 자료실의 디렉토리를 설정한다. ##########

$savedir = "../../product_files";

 

########## 현재페이지의 범위내에 출력할 결과레코드세트를 얻는다. ##########

if(!eregi("[^[:space:]]+",$key)) {

   $query = "SELECT uid,name,part,author,price,remain FROM product ORDER BY uid DESC";

} else {

   $encoded_key = urlencode($key);

   $query = "SELECT uid,name,part,author,price,remain FROM product WHERE $keyfield LIKE '%$key%' ORDER BY uid DESC";

}

$result= mysql_query($query);

if (!$result) {

   error("QUERY_ERROR");

   exit;

}

 

$total_record = mysql_num_rows($result);

 

########## 현재의 페이지에서 출력할 게시물의 범위를 결정한다. ##########

if(!$total_record) {

   $first = 1;

   $last = 0;   

} else {

   $first = $num_per_page*($page-1);

   $last = $num_per_page*$page;

 

   $IsNext = $total_record - $last;

   if($IsNext > 0) {

      $last -= 1;

   } else {

      $last = $total_record - 1;

   }      

}

 

########## 전체 페이지수를 계산한다. ##########

$total_page = ceil($total_record/$num_per_page);

?>

 

<form name="signform" method="post" action="read.html?page=<?echo("$page")?>&keyfield=<?echo("$keyfield")?>&key=<?echo("$encoded_key")?>">

 

<table width=600 border="0" align="center" cellspacing="0" cellpadding="0">

<tr>

   <td align=center height=30><b><font size=4>경매 제품 선택</font></b></td>

</tr>

</table>

<table width=600 border="0" align="center" cellspacing="0" cellpadding="0">

<tr>

   <td width="80">&nbsp;</td>

   <td width="340" align="center">

   <font size="2">   

<?

if(!eregi("[^[:space:]]+",$key)) {

   echo("총 등록된 자료 : <b>$total_record</b> (Total <b>$total_record</b> Files)");

} else {

   echo("검색된 자료 : <b>$total_record</b> (Total <b>$total_record</b> Files)");

}

?>

   </font>

   </td>

   <td width="80" align="right"><font size=2>( <font color="red"><? echo("$page") ?></font> / <font color="red"><? echo("$total_page") ?></font> )</font></td>

</tr>

</table>

<table width=600 border=0 cellpadding=1 cellspacing="0" align="center">

<tr>

   <td bgColor="#000000">

<table border="0" width=600 align="center" cellspacing="1" cellpadding="2">

<tr>

   <td align="center" bgColor=#BBBBBB width=40>

   <font size=2 color="#000000">번호</font></td>

   <td align="center" bgColor=#BBBBBB width=100>

   <font size=2 color="#000000">분류</font></td>

   <td align="center" bgColor=#BBBBBB width=200>

   <font size=2 color="#000000">제목</font></td>

   <td align="center" bgColor=#BBBBBB width=70>

   <font size=2 color="#000000">지은이</font></td>

   <td align="center" bgColor=#BBBBBB width=70>

   <font size=2 color="#000000">가격</font></td>

   <td align="center" bgColor=#BBBBBB width=40>

   <font size=2 color="#000000">수량</font></td>

   <td align="center" bgColor=#BBBBBB width=80>

   <font size=2 color="#000000">경매등록</font></td>

</tr>

<?

$time_limit = 60*60*24*$notify_new_article;

 

########## 게시물의 가상번호(게시물의 개수에 따른 일련번호) ##########

$article_num = $total_record - $num_per_page*($page-1);

 

for($i = $first; $i <= $last; $i++) {

   $my_uid = mysql_result($result,$i,0);

   $my_name = mysql_result($result,$i,1);

   $my_part = mysql_result($result,$i,2);

   $my_author = mysql_result($result,$i,3);

   $my_price = mysql_result($result,$i,4);

   $my_remain = mysql_result($result,$i,5);

 

   ########## addslashes() 함수로 escape된 제목의 문자열을 원상복귀시킨다. ##########

   $my_subject = stripslashes($my_subject);

 

   echo("<tr>");

   echo("   <td bgColor=#EEEEEE align=\"center\"><font size=2>$article_num</font></td>");

   echo("<td bgColor=#EEEEEE align=\"center\"><font size=2>$my_part</font></td>");

   echo("<td bgColor=#EEEEEE align=\"center\">&nbsp;<font size=2>$my_name</font></td>\n");

   echo("<td bgColor=#EEEEEE align=\"center\"><font size=2>$my_author</font></td>");

   echo("<td bgColor=#EEEEEE align=\"center\"><font size=2>$my_price</font></td>");

   echo("<td bgColor=#EEEEEE align=\"center\"><font size=2>$my_remain</font></td>");

   echo("<td bgColor=#EEEEEE align=\"center\"><font size=2><a href='postform.html?number=$my_uid'><font size=2>[선택하기]</a></font></td>");

   echo("</tr>");      

   $article_num--;

}

echo("</table>");

?>

</td></tr>

</table>

 

<table width=600 border="0" cellspacing="0" cellpadding="0" align="center">

<tr>

   <td colspan="7" align="center">

<?

########## 게시물 목록 하단의 각 페이지로 직접 이동할 수 있는 페이지링크에 대한 설정을 한다. ##########

$total_block = ceil($total_page/$page_per_block);

$block = ceil($page/$page_per_block);

 

$first_page = ($block-1)*$page_per_block;

$last_page = $block*$page_per_block;

 

if($total_block <= $block) {

   $last_page = $total_page;

}

 

########## 이전페이지블록에 대한 페이지 링크 ##########

if($block > 1) {

   $my_page = $first_page;

   echo("<font size=2><a href=\"prod_list.html?page=$my_page&keyfield=$keyfield&key=$encoded_key\" >[이전 ${page_per_block}개]</a></font>");

}

 

########## 현재의 페이지 블럭범위내에서 각 페이지로 바로 이동할 수 있는 하이퍼링크를 출력한다. ##########

for($direct_page = $first_page+1; $direct_page <= $last_page; $direct_page++) {

   if($page == $direct_page) {

      echo("<font size=2><b>[$direct_page]</b></font>");

   } else {

      echo("<font size=2><a href=\"prod_list.html?page=$direct_page&keyfield=$keyfield&key=$encoded_key\">[$direct_page]</a></font>");

   }

}

########## 다음페이지블록에 대한 페이지 링크 ##########

if($block < $total_block) {

   $my_page = $last_page+1;

   echo("<font size=2><a href=\"prod_list.html?page=$my_page&keyfield=$keyfield&key=$encoded_key\" onMouseOver=\"status='load next $page_per_block pages';return true;\" onMouseOut=\"status=''\">[다음 ${page_per_block}개]</a></font>");

}

?>   

   </td>

</tr>

</table>

<table width=600 border="0" cellspacing="0" cellpadding="0" align="center">

<tr>

   <td align="left">

   <a href="list.html" >경매목록</a> |

   <a href="prod_list.html" >제품목록</a>

   </td>

   <td align="right"><font size=2>

 

<?

########## 이전페이지가 존재할 경우 이전페이지로 가는 링크를 활성화시킨다. ##########

if ($page > 1) {

   $page_num = $page - 1;

   echo("<a href=\"prod_list.html?page=$page_num&keyfield=$keyfield&key=$encoded_key\">이전</a> | ");

} else {

   echo("이전 | ");

}

########## 게시물이 다음페이지에도 존재할 경우 다음페이지로 가는 링크를 활성화시킨다. ##########

if ($IsNext > 0) {

   $page_num = $page + 1;   

   echo("<a href=\"prod_list.html?page=$page_num&keyfield=$keyfield&key=$encoded_key\">다음</a> </td>");

} else {

   echo("다음</td>");

}

?>

</tr>

</table>

</form>

<center>

<form method="post" action="prod_list.html">

<font size=-1>

<select name="keyfield" size="1">

   <option value="name">제목</option>

   <option value="author">지은이</option>

   <option value="info">내용</option>

</select>

</font>

<input type="text" size="20" maxlength="30" name="key">

<font size=2><input type="submit" value="검색"></font>

</form>

</center>

</body>

</html>

 

5. 경매제품 수정하기(관리자)

파일명 : modifyform.hrml

 <?

/*

유닉스 타임을 대입하면 2000-08-10 10:20:30 와 같은 방식으로 값을 리턴하는 사용자정의 함수 ymdhis()를 정의한다.

*/

function ymdhis($t){

return date("Y-m-d H:i:s",$t);

}

$nowdate=ymdhis(time());

 

/*

mkunixtime()은 2000-08-10 10:20:30 와 같은 방식으로 되어 있는 일자 값을 분석하여 유닉스 타임으로 시각값을 리턴하는 사용자정의 함수이다.

mkunixtime($ymdhis,0,0,0,0,2,0)->2일

*/

function mkunixtime($ymdhis,$ha,$ia,$sa,$ma,$da,$ya){

$ymdhisa=explode(" ",$ymdhis);

$ymda=explode("-",$ymdhisa[0]);

$hisa=explode(":",$ymdhisa[1]);

$y=$ymda[0];

$m=$ymda[1];

$d=$ymda[2];

$h=$hisa[0];

$i=$hisa[1];

$s=$hisa[2];

return mktime($h+$ha,$i+$ia,$s+$sa,$m+$ma,$d+$da,$y+$ya);

}

 

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

 

if($auc_uid) {

 

        $res = mysql_query("select * from auction where uid = '$auc_uid'");

        $rs = mysql_fetch_array($res);

 

        if ($rs[stdate] > $nowdate){

        mysql_query("update auction set bidstat = '0' where uid='$auc_uid'");

        }

        if ($rs[stdate] <= $nowdate && $rs[enddate] >= $nowdate){

        mysql_query("update auction set bidstat = '1' where uid='$auc_uid'");

        }

        if ($rs[enddate] < $nowdate){

        mysql_query("update auction set bidstat = '2' where uid='$auc_uid'");

        }

 

 

        $query = "SELECT uid,prod_uid,stprice,stdate,enddate,etc,bidstat FROM auction where uid = '$auc_uid'";

        $result = mysql_query($query,$dbconn);

   if (!$result) {

       error("QUERY_ERROR");

       exit;

   }

        $total_record = mysql_num_rows($result);

 

        if($total_record) {

   

        $uid = mysql_result($result,0,0);

        $prod_uid = mysql_result($result,0,1);

        $stprice = mysql_result($result,0,2);

        $stdate = mysql_result($result,0,3);

        $enddate = mysql_result($result,0,4);

        $etc = mysql_result($result,0,5);

        $bidstat = mysql_result($result,0,6);

 

           $query1="SELECT uid,name,part,info FROM product WHERE uid=$prod_uid ";

           $result1 = mysql_query($query1);

           if (!$result1) {

                   error("QUERY_ERROR");

                   exit;

           }

                $total_record1 = mysql_num_rows($result1);

                if($total_record1) {

                   $prod_uid = mysql_result($result1,0,0);   

                   $prod_name = mysql_result($result1,0,1);   

                   $prod_part = mysql_result($result1,0,2);   

                   $prod_info = mysql_result($result1,0,3);   

                 }

        }

 

} else {

    echo ("<meta http-equiv='Refresh' content='0; URL=./list.html?keyfield=$keyfield&key=$key'>");

        exit;

}

?>

<HTML>

<HEAD>

<TITLE> 경매제품 등록 </TITLE>

<style type="text/css">

//<!--

A:hover {  text-decoration: underline;  color: #CC0000; font-size: 9pt}

a:link {  text-decoration: none}

a:visited {  text-decoration: none}

td {  font-size: 9pt; font-family: "굴림"}

.retextwite { font-family: "굴림"; font-size: 9pt; color: #FFFFFF; text-decoration: none ; line-height: 12pt }

.text { font-family: "굴림"; font-size: 9pt; text-decoration: none ; color: #000000}

 

//-->

</style>

 

</HEAD>

<body bgcolor="#EEEEEE">

 <b></b>

<table width="100%" border="0" cellspacing="0" cellpadding="0" >

  <tr align="center">

    <td>  <br>

      <table width="308" border="0" cellspacing="0" cellpadding="0" height="25" >

                          <tr align="center" valign="middle">

          <td><font size=4">아울쇼핑센터 경매 등록 정보</font></td>

                          </tr>

                        </table>

    

      <form method="post" action="modify.html?<?echo("number=$uid&keyfield=$keyfield&key=$key");?>"  name="upform">

        <script>

function checkformin(){

var theform;

theform=document.upform;

 

if (theform.prod_uid.value==""){

window.alert("제품을 선택해 주세요.");

theform.prod_uid.focus();

return false;

} else if (theform.stprice.value==""){

window.alert("시작가격을 입력해 주세요.");

theform.stprice.focus();

return false;

}else if (theform.stprice.value < 0 ){

window.alert("가격과 기간은 음수일 수 없습니다.");

theform.stprice.focus();

return false;

}else{

theform.submit();

}

return false;

}

</script>

        <table width="500" border="0" cellspacing="0" cellpadding="2" bgcolor="#6666FF">

          <tr valign="top">

            <td colspan="2">

              <table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#6666FF">

                <tr>

                  <td width="50" class="retextwite">분류코드</td>

                  <td width="437" bgcolor="#6666FF">

                    <input type="TEXT" name="prod_uid"  readonly  value="<?echo("$prod_part");?>">

                  </td>

                </tr>

              </table>

              

            </td>

          </tr>

          <tr valign="top">

            <td width="250"  bgcolor="#FFFFFF" align="center">

              <table width="100%" border="0" cellspacing="0" cellpadding="2">

                <tr>

                  <td width="81" bgcolor="#FFFFFF">제품명</td>

                  <td width="161" bgcolor="#FFFFFF">

                    <input type="TEXT" name="prod_name"  readonly  value="<?echo("$prod_name");?>">

                  </td>

                </tr>

                <tr>

                  <td width="81" bgcolor="#ECECFF">제품코드</td>

                  <td width="161" bgcolor="#ECECFF">

                    <input type="TEXT" name="prod_uid"  readonly  value="<?echo("$prod_uid");?>">

                  </td>

                </tr>

                <tr bgcolor="#FFFFFF">

                  <td width="81">시작가격</td>

                  <td width="161">

                    <input type="TEXT" name="stprice" value="<?echo("$stprice");?>">

                  </td>

                </tr>

                <tr bgcolor="#ECECFF">

                  <td>경매시작일자</td>

                  <td>

                    <input type="TEXT" name="stdate" value="<?echo("$stdate");?>">

                    </td>

                </tr>

                <tr bgcolor="#FFFFFF">

                  <td width="81">경매마감일자</td>

                  <td width="161">

                    <input type="TEXT" name="enddate" value="<?echo("$enddate");?>">

                    </td>

                </tr>

                <tr bgcolor="#ECECFF">

                  <td>경매상태</td>

                  <td>

                    <?

if ($bidstat==0)echo "경매전";

if ($bidstat==1){

echo "경매중";?> <font color="#FF3333">마감 <?

$deadlineall = mkunixtime($enddate,0,0,0,0,0,0) - mkunixtime($nowdate,0,0,0,0,0,0);

$deadlines = ($deadlineall % 60);

$deadlinei = intval($deadlineall / 60);

if ($deadlinei>=60) $deadlineh = intval($deadlinei / 60); $deadlinei = $deadlinei % 60;

 

if ($deadlineh>0)echo $deadlineh."시간 ";

if ($deadlineh>0 || $deadlinei>0)echo $deadlinei."분 ";

echo $deadlines."초";

?> 전</font><?

}

if ($bidstat==2)echo "경매종료";

?>

                    </td>

                </tr>

              </table>

              

              

            </td>

            <td width="250" align="right" valign="top" bgcolor="#ECECFF"> 제품요약정보<br>

              <textarea name="prod_info" cols="30"  readonly  rows="7"><?echo("$prod_info");?></textarea>

              <br>

              <br>

              경매정보<br>

              <textarea name="etc" cols="30" rows="7"><?echo("$etc");?></textarea>

            </td>

          </tr>

        </table>

        <input type="button" name="Submit4" value="경매수정"  onclick="checkformin()">

        <input type="button" name="Submit53" value="경매목록" onClick="self.location='list.html?page=<?echo("$page");?>'">

      </form>

        </td>

  </tr>

</table>

</body>

</html>

 

파일명 : modify.hrml

<?

/*

유닉스 타임을 대입하면 2000-08-10 10:20:30 와 같은 방식으로 값을 리턴하는 사용자정의 함수 ymdhis()를 정의한다.

*/

function ymdhis($t){

return date("Y-m-d H:i:s",$t);

}

 

/*

mkunixtime()은 2000-08-10 10:20:30 와 같은 방식으로 되어 있는 일자 값을 분석하여 유닉스 타임으로 시각값을 리턴하는 사용자정의 함수이다.

mkunixtime($ymdhis,0,0,0,0,2,0)->2일

*/

function mkunixtime($ymdhis,$ha,$ia,$sa,$ma,$da,$ya){

$ymdhisa=explode(" ",$ymdhis);

$ymda=explode("-",$ymdhisa[0]);

$hisa=explode(":",$ymdhisa[1]);

$y=$ymda[0];

$m=$ymda[1];

$d=$ymda[2];

$h=$hisa[0];

$i=$hisa[1];

$s=$hisa[2];

return mktime($h+$ha,$i+$ia,$s+$sa,$m+$ma,$d+$da,$y+$ya);

}

 

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

 

if($number) {

 

        $query1 = "update auction set stprice='$stprice',stdate='$stdate',enddate='$enddate',etc='$etc' where uid = '$number'";

 

        $result1 = mysql_query($query1);

        if (!$result1) {

                error("QUERY_ERROR");

                exit;

        }

        echo ("<meta http-equiv='Refresh' content='0; URL=./list.html?page=$page'>");

}

else {

        echo ("<meta http-equiv='Refresh' content='0; URL=./modifyform.html?page=$page'>");

}

?>

 

6. 경매제품 삭제하기(관리자)

파일명 : deleteform.hrml

<?

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

 

if($number) {

 

        $query = "SELECT uid,prod_uid,stprice,stdate,enddate,etc,bidstat FROM auction where uid = '$number'";

        $result = mysql_query($query,$dbconn);

   if (!$result) {

       error("QUERY_ERROR");

       exit;

   }

        $total_record = mysql_num_rows($result);

 

        if($total_record) {

   

        $uid = mysql_result($result,0,0);

        $prod_uid = mysql_result($result,0,1);

        $stprice = mysql_result($result,0,2);

        $stdate = mysql_result($result,0,3);

        $enddate = mysql_result($result,0,4);

        $etc = mysql_result($result,0,5);

        $bidstat = mysql_result($result,0,6);

 

           $query1="SELECT uid,name,part,info FROM product WHERE uid=$prod_uid ";

           $result1 = mysql_query($query1);

           if (!$result1) {

                   error("QUERY_ERROR");

                   exit;

           }

                $total_record1 = mysql_num_rows($result1);

                if($total_record1) {

                   $prod_uid = mysql_result($result1,0,0);   

                   $prod_name = mysql_result($result1,0,1);   

                   $prod_part = mysql_result($result1,0,2);   

                   $prod_info = mysql_result($result1,0,3);   

                 }

        }

 

} else {

    echo ("<meta http-equiv='Refresh' content='0; URL=./list.html?keyfield=$keyfield&key=$key'>");

        exit;

}

?>

<HTML>

<HEAD>

<TITLE> 경매관리 - 삭제하기 </TITLE>

</HEAD>

 

<style type="text/css">

//<!--

A:hover {  text-decoration: underline;  color: #CC0000; font-size: 9pt}

a:link {  text-decoration: none}

a:visited {  text-decoration: none}

td {  font-size: 9pt; font-family: "굴림"}

.retextwite { font-family: "굴림"; font-size: 9pt; color: #FFFFFF; text-decoration: none ; line-height: 12pt }

.text { font-family: "굴림"; font-size: 9pt; text-decoration: none ; color: #000000}

 

//-->

</style>

<body bgcolor="#EEEEEE">

 <b></b>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr align="center">

    <td>  <br>

      <table width="308" border="0" cellspacing="0" cellpadding="0" height="25" >

                          <tr align="center" valign="middle">

                            

          <td > <font size=4>아울쇼핑센터 경매 등록 정보</td>

                          </tr>

                        </table>

  

      <form method="post" action="delete.html?number=<?echo("$number");?>"  name="del">

        <b> 삭제</b><br>              

다음 제품을 삭제합니다.

        <strong><br>

        <br>

        </strong>

        <table>

          <tr>

            <td align="right"> 경매번호 : </td>

            <td>&nbsp;<?echo("$number");?></td>

          </tr>

          <tr>

            <td align="right"> 등록일자 : </td>

            <td>&nbsp;<?echo("$stdate");?></td>

          </tr>

          <tr>

            <td align="right"> 제품코드 : </td>

            <td>&nbsp;<?echo("$prod_uid");?>

            </td>

          </tr>

          <tr>

            <td align="right"> 제품명 : </td>

            <td>&nbsp;<?echo("$prod_name");?>

            </td>

          </tr>

          <tr>

            <td align="right"> 분류코드 : </td>

            <td>&nbsp;<?echo("$prod_part");?></td>

          </tr>

          <tr>

            <td align="right"> </td>

            <td>

              <input type="submit" name="del" value="삭제">

              <input type="button" name="Submit52" value="제품목록" onClick="self.location='list.html?page=<?echo("$page");?>'">

            </td>

          </tr>

        </table>

</form>

          </td>

  </tr>

</table>

</body>

</html>

 

 

파일명 : delete.hrml

<?

/*

유닉스 타임을 대입하면 2000-08-10 10:20:30 와 같은 방식으로 값을 리턴하는 사용자정의 함수 ymdhis()를 정의한다.

*/

function ymdhis($t){

return date("Y-m-d H:i:s",$t);

}

$nowdate=ymdhis(time());

 

/*

mkunixtime()은 2000-08-10 10:20:30 와 같은 방식으로 되어 있는 일자 값을 분석하여 유닉스 타임으로 시각값을 리턴하는 사용자정의 함수이다.

mkunixtime($ymdhis,0,0,0,0,2,0)->2일

*/

function mkunixtime($ymdhis,$ha,$ia,$sa,$ma,$da,$ya){

$ymdhisa=explode(" ",$ymdhis);

$ymda=explode("-",$ymdhisa[0]);

$hisa=explode(":",$ymdhisa[1]);

$y=$ymda[0];

$m=$ymda[1];

$d=$ymda[2];

$h=$hisa[0];

$i=$hisa[1];

$s=$hisa[2];

return mktime($h+$ha,$i+$ia,$s+$sa,$m+$ma,$d+$da,$y+$ya);

}

 

include "../../user_function.html";

include "../../dbconn.html";

 

include("../admin.html");

 

if(!$user_id || strcmp($row->logindate,$user_logindate)) {

      echo ("<meta http-equiv='Refresh' content='0; URL=../'>");

      exit;

}

 

if($number) {

        $query1 = "delete from auction where uid = $number";

 

        $result1 = mysql_query($query1);

        if (!$result1) {

                error("QUERY_ERROR");

                exit;

        }

        $query1 = "delete from bid where auction_uid = $number";

 

        $result1 = mysql_query($query1);

        if (!$result1) {

                error("QUERY_ERROR");

                exit;

        }

        echo ("<meta http-equiv='Refresh' content='0; URL=./list.html?page=$page'>");

}

else {

        echo ("<meta http-equiv='Refresh' content='0; URL=./deleteform.html?page=$page'>");

}

?>

 

 

[목차]

개인정보취급방침 서비스이용약관 모바일 버전으로 보기 상단으로

TEL. 063-469-4551 FAX. 063-469-4560 전북 군산시 대학로 558
군산대학교 컴퓨터정보공학과

Copyright © www.leelab.co.kr. All rights reserved.