Web Programming >> PHP Programming
|
[목차] |
제26장 쇼핑몰 만들기 3 - 이벤트 경매
2. 경매 및 낙찰 처리 (일반 사용자용)
사용자 화면은 경매에 입찰하고, 낙찰 되었을 때 주문하는 처리가 필요하다. 필요한 프로그램들 다음과 같다. / -- shop/ -- admin/ --- auction/ --(경매관리-> 추가되는 부분) | | | | | +-- list.html | | +-- postform.html | | +-- post.html | | +-- prod_list.html | | +-- modifyform.html | | +-- modify.html | | +-- deleteform.html | | +-- delete.html | +- menu.html (관리자 메뉴 수정) +-- menu.html (쇼핑몰 메뉴 수정) | +-- welcome.html (메인화면에 경매상품 추가) +-- auction_list.html (경매상품 목록 보기) +-- auction_in.html (경매상품 세부내역보기) +-- auction_in_process.html (입찰하기) +-- auction_my.html (낙찰목록) +-- auction_my_process.html (쇼핑백에 담기) +-- order.html (주문자 신상명세 입력화면)
1. 메뉴 추가하기(사용자) 파일명 : menu.hrml <? session_start(); include "./user_function.html"; include "./dbconn.html";
?> <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="#EEEEEE"> <br> <? if($user_id) { echo("<center><font size=2>$user_id 님께서<br>접속하였습니다.</font><br>"); ?> <A HREF="./logout.html" target="_top">접속종료</A><p></center> <?}else {?> <LI> <A HREF="./login.html" target="bookshop-main-detail">로그인</A><br> <LI> <A HREF="./register/registerform.html" target="bookshop-main-detail">회원가입</A><p> <?}?> <LI> <A HREF="./" target="_top">홈으로</A><p> <? $query = "SELECT DISTINCT part FROM product order by part";
$result= mysql_query($query); if (!$result) { error("QUERY_ERROR"); exit; }
$total_record = mysql_num_rows($result); for($i = 0; $i < $total_record; $i++) { $my_part = mysql_result($result,$i,0);
?> <LI> <A HREF="list.html?part=<?echo $my_part;?>" target="bookshop-main-detail"><?echo $my_part;?></A> <?}?> <p> <LI> <A HREF="auction_list.html" target="bookshop-main-detail">경매</A> <LI> <A HREF="auction_my.html" target="bookshop-main-detail">낙찰</A> <LI> <A HREF="list_bag.html" target="bookshop-main-detail">장바구니보기</A> </BODY> </HTML>
2. 메인 화면에 경매상품 보여주기 파일명 : welcome.hrml <? session_start();
include "./user_function.html"; include "./dbconn.html";
$imgdir = "./product_files";
if(!$user_uid) {
$result = mysql_query("SELECT max(uid)+1 FROM sold"); if (!$result) { error("QUERY_ERROR"); exit; } $new_uid = (int)mysql_result($result,0,0);
$query = "INSERT INTO sold (uid) VALUES ($new_uid)"; $result = mysql_query($query); if (!$result) { error("QUERY_ERROR"); exit; }
session_register("user_uid"); $user_uid = $new_uid; }
?> <HTML> <HEAD> <TITLE> 환영합니다. </TITLE> <style type="text/css"> <!-- a:link,a:visited,a:active { text-decoration : none; } a:hover { text-decoration : underline; color : red; } TABLE, TD, TR, TH { font-size : 10pt; } //--> </style> <script language="javascript"> <!-- function view_product_Window( ref ) { var window_left = (screen.width-450)/2; var window_top = (screen.height-450)/2; window.open(ref,"profilewindow",'width=450,height=450,status=no,scrollbars=yes,top=' + window_top + ',left=' + window_left + ''); } //--> </script>
</HEAD> <BODY BGCOLOR="#EEEEEE"> <br> <center> <h1>방문을 환영합니다. </h1> </center> <br> <br> <table border="0" cellpadding="0" width="100%" align=left> <tr> <td align=center> <?
$query1 = "SELECT uid,name,author,price,userfile,info FROM product WHERE suggest > 0 ORDER BY suggest ";
$result1 = mysql_query($query1); if (!$result1) { error("QUERY_ERROR"); exit; } $total_record1 = mysql_num_rows($result1);
?> <!--추천상품 시작--> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <font color="#000000" size=4><b>추천상품</b></font> </td> </tr> </table> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="2" > <tr align="center" valign="top">
<? $n=0;
for($i = 0; $i < $total_record1; $i++) { $my_p_uid = mysql_result($result1,$i,0); $my_p_name = mysql_result($result1,$i,1); $my_p_author = mysql_result($result1,$i,2); $my_p_price = mysql_result($result1,$i,3); $my_p_imgname = mysql_result($result1,$i,4); $my_p_info = mysql_result($result1,$i,5);
if ($n!=0 && $n%4==0)echo "</tr><tr align='center' valign='top'>";
?> <td> <br> <?if($my_p_imgname == ""){ echo("<font color=red>그림없음<p>"); }else {?> <img src=<?echo("$imgdir/$my_p_imgname");?> border=0> <?}?> <font size=2 color=black> <a href="javascript:view_product_Window('viewproduct.html?number=<?echo("$my_p_uid");?>')"><?echo("$my_p_name");?></a><br> 판매가 : <?echo("$my_p_price");?></font><br> </td> <? } ?> <?if ($total_record1 == 0)echo "<td height=150><br><br><br><br>현재 경매로 올라온 상품이 없습니다...... </td>";?></tr> </table> </td> </tr> </table> <p> <!--추천상품 끝--> <!--경매상품 시작--> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <font color="#000000" size=4><b>경매상품</b></font> </td> </tr> </table> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="2" > <tr align="center" valign="top"> <? /* 유닉스 타임을 대입하면 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); } ?> <? $query = "select * from auction where bidstat = '0' or bidstat = '1'"; $res = mysql_query($query); if ($res){ while($rs = mysql_fetch_array($res)){
if ($rs[stdate] > $nowdate && $rs[bidstat] == 1){ mysql_query("update auction set bidstat = '0' where uid='$rs[uid]'"); } if ($rs[stdate] <= $nowdate && $rs[enddate] >= $nowdate && $rs[bidstat] == 0){ mysql_query("update auction set bidstat = '1' where uid='$rs[uid]'"); } if ($rs[enddate] < $nowdate){ mysql_query("update auction set bidstat = '2' where uid='$rs[uid]'"); } }//while }//if
$aucipp=4; $query = "select * from auction where bidstat = '1' order by enddate limit $aucipp"; $res=mysql_query($query); if (!$res) { error("QUERY_ERROR"); exit; }
$n=0; while($rs=mysql_fetch_array($res)){
//입찰수 $bidcount=0; $query = "select myprice from bid where auction_uid = '$rs[uid]' order by uid DESC"; $resal=mysql_query($query); if (!$resal) { error("QUERY_ERROR"); exit; } $total = mysql_num_rows($resal); $myprice = 0; if($total) { $myprice=mysql_result($resal,0,0); }
//제품정보 $rsprod=""; if ($rs[prod_uid]){ $resprod=mysql_query("select * from product where uid = '$rs[prod_uid]' "); if ($resprod) $rsprod=mysql_fetch_array($resprod); }
if ($n!=0 && $n%4==0)echo "</tr><tr align='center' valign='top'>"; ?> <td> <br> <a href="auction_in.html?number=<?echo $rs[uid];?>"><?if (is_file("./product_files/".$rsprod[userfile])){echo("<img src=\"./product_files/$rsprod[userfile]\" width=\"70\" height=\"90\" border=\"0\">"); }else{ echo("<font size=2 color=red >그림없음<p></font>");}?> <br> <?echo $rsprod[name];?></a><br> 현재가:<? if($myprice) echo number_format($rs[myprice]); else echo number_format($rs[stprice]);?>원<br> <?if ($rsprod[price]){?> (정가:<?echo number_format($rsprod[price]);?>원)<br> <?}//if?> <font color="#FF3333"><?if ($rs[bidstat]==1){ ?>마감 <? $deadlineall = mkunixtime($rs[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."분 "; if ($deadlineh<=0)echo $deadlines."초"; ?> 전<?}?></font> </td> <? $n++; } ?> <?if (mysql_num_rows($res)==0)echo "<td height=150><br><br><br><br>현재 경매로 올라온 상품이 없습니다...... </td>";?></tr> </table> </td> </tr> </table> <!--경매상품 끝--> <br><br> </td></tr> </table>
</BODY> </HTML>
3. 경매목록 보기 파일명 : auction_list.hrml <? session_start();
include "./user_function.html"; include "./dbconn.html";
$imgdir = "./product_files";
if(!$user_uid) {
$result = mysql_query("SELECT max(uid)+1 FROM sold"); if (!$result) { error("QUERY_ERROR"); exit; } $new_uid = (int)mysql_result($result,0,0);
$query = "INSERT INTO sold (uid) VALUES ($new_uid)"; $result = mysql_query($query); if (!$result) { error("QUERY_ERROR"); exit; }
session_register("user_uid"); $user_uid = $new_uid; }
/* 유닉스 타임을 대입하면 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); }
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 "; $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> <style type="text/css"> <!-- a:link,a:visited,a:active { text-decoration : none; } a:hover { text-decoration : underline; color : red; } TABLE, TD, TR, TH { font-size : 10pt; } //--> </style> </head> <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red"> <p> <table border="0" cellpadding="0" width="100%" align=left> <tr> <td align=center> <table width="308" border="0" cellspacing="0" cellpadding="0" height="25"> <tr align="center" valign="middle">
<td ><font size=4>경매 목록</font></td> </tr> </table>
<table border="0" width="500" align="center" cellspacing="0" cellpadding="0"> <tr><td colspan=2><hr size=1></td></tr> <? 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,price,userfile 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); $prod_price = mysql_result($result1,0,2); $prod_file = mysql_result($result1,0,3);
$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); else $last_price = $stprice; ?> <tr> <td align="center"> <table width="300" border="0" cellspacing="0"> <tr> <td> ●<b><a href="auction_in.html?number=<?echo $uid;?>"><?echo $prod_name;?></a></b><br> ●최종가: <b><?echo number_format($last_price);?></b>원 <?if ($prod_price){?>(<?echo number_format($prod_price);?>원)<?}//if?><br> ●마감: <font color=red><?echo $enddate;?></font> <br> ●입찰수: <?echo $bid_total;?> (<?if ($bidstat==1){ ?><? $deadlineall=0;$deadlineh=0;$deadlinei=0;$deadlines=0; $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."분"; if ($deadlineh<=0)echo $deadlines."초"; ?>전<?}?>)</td> </tr> </table>
</td> <td bgcolor="#FFFFFF" align="center" width=150><a href="auction_in.html?number=<?echo $uid;?>"><? if($prod_file && file_exists("./product_files/$prod_file")) {?> <img src="./product_files/<?echo $prod_file;?>" width="60" height="70" border="0" vspace="4" hspace="4" > <?}else echo ("그림없음");?></a></td> </tr> <tr><td colspan=2><hr size=1></td></tr>
<? } echo("</table>"); ?> <br><br> </td></tr> </table> </body> </html>
4. 경매제품 세부내역 보기 파일명 : auction_in.hrml <? session_start();
include "./user_function.html"; include "./dbconn.html";
$imgdir = "./product_files";
if(!$user_uid) {
$result = mysql_query("SELECT max(uid)+1 FROM sold"); if (!$result) { error("QUERY_ERROR"); exit; } $new_uid = (int)mysql_result($result,0,0);
$query = "INSERT INTO sold (uid) VALUES ($new_uid)"; $result = mysql_query($query); if (!$result) { error("QUERY_ERROR"); exit; }
session_register("user_uid"); $user_uid = $new_uid; }
/* 유닉스 타임을 대입하면 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); }
$res = mysql_query("select * from auction where uid='$number'"); if ($res){ while($rs = mysql_fetch_array($res)){
if ($rs[stdate] > $nowdate && $rs[bidstat] == 1){ mysql_query("update auction set bidstat = '0' where uid='$rs[uid]'"); } if ($rs[stdate] <= $nowdate && $rs[enddate] >= $nowdate && $rs[bidstat] == 0){ mysql_query("update auction set bidstat = '1' where uid='$rs[uid]'"); } if ($rs[enddate] < $nowdate){ $resend=mysql_query("select * from bid where auction_uid='$rs[uid]' order by signdate desc limit 1"); $rsend=mysql_fetch_array($resend); mysql_query("update auction set bidstat = '2', winner='$rsend[user_id]' where uid='$rs[uid]'"); } }//while }//if
$rs=""; $res = mysql_query("select * from auction where uid='$number'"); if ($res) $rs=mysql_fetch_array($res);
$rsprod=""; if ($rs[prod_uid]){ $resprod=mysql_query("select * from product where uid = '$rs[prod_uid]' "); if ($resprod) $rsprod=mysql_fetch_array($resprod); }
?> <HTML> <HEAD> <TITLE> 경매입찰 </TITLE> <style type="text/css"> <!-- a:link,a:visited,a:active { text-decoration : none; } a:hover { text-decoration : underline; color : red; } TABLE, TD, TR, TH { font-size : 10pt; } //--> </style>
</HEAD>
<BODY BGCOLOR="#EEEEEE"> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr align="center"> <td> <a name="in"></a> <table border="0" cellspacing="0" cellpadding="0" align="center"> <tr align="center"> <td> <table width="189" border="0" cellspacing="0" cellpadding="0" height="51"> <tr align="center"> <td ><br> <br><font size=4 color=blue><b>경매입찰</b><p></font></td> </tr> </table> </td> </tr> <tr> <td> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td align=center> <font size=3 color=black><b><?echo $rsprod[name];?></b></font> <hr> </td> </tr> <? //입찰수 $bidcount=0; $resal=mysql_query("select myprice from bid where auction_uid = '$rs[uid]' order by uid DESC "); $bidcount=mysql_num_rows($resal);
//최종입찰정보 $rslast=""; if ($bidcount) { $rslast=mysql_fetch_array($resal); $last_price = $rslast[myprice]; } else $last_price = $rs[stprice];
?>
<tr> <td width="100%" align=center> <table border="0" cellspacing="0" cellpadding="0" height="235" width="427" align="center"> <tr> <td> <table width="213" border="0" cellspacing="0" cellpadding="0" height="235"> <tr> <td> <form action="auction_in_process.html"> <input type=hidden name=auction_uid value="<?echo $number;?>">
● 현재시각: <?echo $nowdate;?> <br> <br>
<?if ($rs[bidstat]=='1'){?> 다음 입력란에 입찰금액을 입력하시고, 입찰버튼을 클릭하십시오.<br> <br> <input type="text" name="myprice" value="<?echo $last_price + 1000;?>" size="12"> 원 <input type="submit" name="Submit52" value="입찰하기" > <br> <br> ※주의 : 입찰금액은 최종 입찰 금액에 1,000원 이상 더하여 입찰하십시오. <br> <input type="button" name="Submit43" value="입찰기록보기" onClick="self.location='#his'"> <br> <?}?> <?if ($rs[bidstat]=='2'){?> 본 경매는 <?echo $rs[winner];?> 님에게 <?echo number_format($rslast[myprice]);?> 원에 낙찰처리 되었습니다.<br> <br> 낙찰된 경매품을 거래하시려면 다음의 [낙찰후 거래] 버튼을 클릭하세요.<br> <br> ※주의 : 낙찰일부터 5일내로 결제가 이루어지지 않으면, 낙찰이 자동 취소되며 불량 입찰자로 처리됩니다.<br> <input type="button" name="Submit5" value="낙찰후 거래" class="text" onclick="self.location='auction_my.html'"> <br> <input type="button" name="Submit432" value="입찰기록보기" onClick="self.location='#his'"> <?}?> <?if ($rs[bidstat]=='0'){?> 경매가 시작되지 않았습니다.<br> 본 경매는 <?echo $rs[stdate];?> 에 시작됩니다. <?}?> <?if ($rs[bidstat]=='0'){?> 경매가 시작되지 않았습니다.<br> 본 경매는 <?echo $rs[stdate];?> 에 시작됩니다. <?}?>
</form> </td> </tr> </table> </td> <td> <table width="214" border="1" cellspacing="0" cellpadding="0" height="235"> <tr align="center"> <td><?if($rcprod[userfile] && file_exists("./product_files/$rcprod[userfile]")) {?> <img src="./product_files/<?echo $rcprod[userfile];?>" width="60" height="70" border="0" vspace="4" hspace="4" > <?}else echo ("그림없음");?> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td align="center"> <table width="552" border="1" cellspacing="0" cellpadding="0" height="75"> <tr> <td width="501"> <table width="502" border="0" cellspacing="0" cellpadding="0" height="73"> <tr valign="top"> <td align=center> <table width="350" border="0" cellspacing="0" cellpadding="0" height="100"> <tr> <td ><ul> <li>제품분류 : <?echo $rsprod[part];?><br> <li>최종가격 : <b><?echo $last_price;?> 원</b> (정가:<?echo $rsprod[price];?>원) <br> <li>입찰자수 : <?echo $bidcount;?>명 <br> <li>최종입찰자: <b><?echo $rslast[user_id];?></b> <br> <li>마감: <?echo $rs[enddate];?>까지 (<?if ($rs[bidstat]==1){ ?><? $deadlineall = mkunixtime($rs[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."분"; if ($deadlineh<=0)echo $deadlines."초"; ?>전<?}?>) </ul></td> </tr> </table> </td> <td align=right> <table width="152" border="0" cellspacing="0" cellpadding="0" height="100"> <tr align="right" valign="bottom"> <td> <table border="0" cellspacing="0" cellpadding="2"> <tr align="center" valign="bottom"> <td><a href="auction_list.html"> 목록 </a></td> <td></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <br> <table width="502" border="0" cellspacing="0" cellpadding="1" bgcolor="#BBBBBB"> <tr> <td> <table width="502" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <table width="502" border="1" cellspacing="0" cellpadding="0" > <tr> <td width=100 align=center height=30><font size=2 color="#000000"><b>상세설명</b></font></td> <td align=left><font size=2 color="#000000"> <?echo nl2br($rsprod[info]); ?> </font> </td> </tr> <tr> <td width=100 align=center height=30><font size=2 color="#000000"><b>경매정보</b></font></td> <td align=left><font size=2 color="#000000"> <? echo nl2br($rs[etc]); ?> </font> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <a name="his"></a><br> <table width="502" border="0" cellspacing="0" cellpadding="1" bgcolor="#BBBBBB"> <tr> <td> <table width="502" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <table width="502" border="0" cellspacing="0" cellpadding="0" > <tr> <td height="20">경매 입찰 기록 보기</td> <td height="20" align="right"><a href="#in" >▲위로▲</a></td> </tr> </table> </td> </tr> <tr> <td > <table width="502" border="0" cellspacing="1" cellpadding="3"> <tr align="center"> <td>입찰번호</td> <td>입찰자</td> <td>입찰금액</td> <td>입찰일자</td> </tr> <? ########### 한 페이지당 출력할 게시물의 수 $num_per_page = 5;
########### 게시물 출력목록 하단에 링크를 걸 페이지의 개수 $page_per_block = 5;
########### 페이지 초기화 if(!$page) { $page = 1; }
$query = "SELECT uid,user_id,myprice,signdate FROM bid where auction_uid='$number'"; $query .= " ORDER BY signdate DESC";
$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; } } for($i = $first; $i <= $last; $i++) { $uid = mysql_result($result,$i,0); $bid_user_id = mysql_result($result,$i,1); $myprice = mysql_result($result,$i,2); $signdate = mysql_result($result,$i,3); ?> <tr align="center" bgcolor="#FFFFFF"> <td><?echo $uid;?></td> <td><?echo $bid_user_id;?></td> <td><?echo $myprice;?></td> <td><?echo $signdate;?>(<? $deadlineall = mkunixtime($rs[enddate],0,0,0,0,0,0) - mkunixtime($signdate,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."분"; if ($deadlineh<=0)echo $deadlines."초"; ?>전)</td> </tr> <? } ?> </table> <table width="500" 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="500" 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 "] [ "; 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> </td> </tr> </table> </td> </tr> </table> </BODY> </HTML>
5. 경매제품 입찰에 참여하기 파일명 : auction_in_process.hrml <? session_start();
include "./user_function.html"; include "./dbconn.html";
if($user_id != "") { ########## 현재 로그인한 사용자의 데이터를 회원테이블에서 가져온다. ########## $query = "SELECT logindate FROM member WHERE id = '$user_id'"; $result = mysql_query($query); if(!$result) { error("QUERY_ERROR"); exit; } $rows = mysql_num_rows($result);
if($rows) { $row = mysql_fetch_object($result); } }
if(!$user_id || strcmp($row->logindate,$user_logindate)) { ?> <script> window.alert("로그인을 해야만 경매에 참여할 수 있습니다."); history.go(-1); </script> <? // echo ("<meta http-equiv='Refresh' content='0; URL=./auction_in.html?number=$number'>"); exit; }
$imgdir = "./product_files";
if(!$user_uid) {
$result = mysql_query("SELECT max(uid)+1 FROM sold"); if (!$result) { error("QUERY_ERROR"); exit; } $new_uid = (int)mysql_result($result,0,0);
$query = "INSERT INTO sold (uid) VALUES ($new_uid)"; $result = mysql_query($query); if (!$result) { error("QUERY_ERROR"); exit; }
session_register("user_uid"); $user_uid = $new_uid; }
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); }
$res = mysql_query("select * from auction where uid='$auction_uid'"); if ($res){ while($rs = mysql_fetch_array($res)){
if ($rs[stdate] > $nowdate && $rs[bidstat] == 1){ mysql_query("update auction set bidstat = '0' where uid='$rs[uid]'"); } if ($rs[stdate] <= $nowdate && $rs[enddate] >= $nowdate && $rs[bidstat] == 0){ mysql_query("update auction set bidstat = '1' where uid='$rs[uid]'"); } if ($rs[enddate] < $nowdate){ $resend=mysql_query("select * from auction where groupnum='$rs[groupnum]' order by stepnum desc limit 1"); $rsend=mysql_fetch_array($resend); mysql_query("update auction set bidstat = '2', winner='$rsend[userid]' where uid='$rs[uid]'"); } }//while }//if
$rs=""; $res = mysql_query("select * from auction where uid='$auction_uid'"); if ($res) $rs=mysql_fetch_array($res);
$rsprod=""; if ($rs[prod_uid]){ $resprod=mysql_query("select * from product where uid = '$rs[prod_uid]' "); if ($resprod) $rsprod=mysql_fetch_array($resprod); }
?> <HTML> <HEAD> <TITLE> 경매입찰 - 처리 </TITLE> </HEAD>
<BODY BGCOLOR="#FFFFFF"> <?if ($rs[bidstat]=='2'){?> <script> window.alert("본 경매는 이미 마감되었습니다."); history.go(-1); </script> <?die;}//if?> <?if ($rs[bidstat]=='0'){?> <script> window.alert("본 경매는 아직 시작되지 않았습니다.\r\n<?echo $rs[stdate];?>부터 시작합니다."); history.go(-1); </script> <?die;}//if?> <? ?> <?if ($myprice < $rslast+1000){?> <script> window.alert("<?echo $suserid;?>님께서는 <?echo $myprice;?>원을 입력하셨으나, 현재 최저 입찰 금액은 <?echo $rslast[myprice]+1000;?>원입니다.\r\n입찰 금액을 다시 입력하십시오."); history.go(-1); </script> <?die;}//if?>
<? $query2 = "insert into bid (auction_uid,myprice,user_id,signdate) VALUES ('$auction_uid','$myprice','$user_id',NOW())"; $resin = mysql_query($query2);
echo ("<meta http-equiv='Refresh' content='0; URL=./auction_in.html?number=$auction_uid'>");
?> </BODY> </HTML>
6. 낙찰 목록 보기 파일명 : auction_my.hrml <? session_start();
include "./user_function.html"; include "./dbconn.html";
$imgdir = "./product_files";
if(!$user_uid) {
$result = mysql_query("SELECT max(uid)+1 FROM sold"); if (!$result) { error("QUERY_ERROR"); exit; } $new_uid = (int)mysql_result($result,0,0);
$query = "INSERT INTO sold (uid) VALUES ($new_uid)"; $result = mysql_query($query); if (!$result) { error("QUERY_ERROR"); exit; }
session_register("user_uid"); $user_uid = $new_uid; }
/* 유닉스 타임을 대입하면 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); }
$res = mysql_query("select * from auction where uid='$number'"); if ($res){ while($rs = mysql_fetch_array($res)){
if ($rs[stdate] > $nowdate && $rs[bidstat] == 1){ mysql_query("update auction set bidstat = '0' where uid='$rs[uid]'"); } if ($rs[stdate] <= $nowdate && $rs[enddate] >= $nowdate && $rs[bidstat] == 0){ mysql_query("update auction set bidstat = '1' where uid='$rs[uid]'"); } if ($rs[enddate] < $nowdate){ $resend=mysql_query("select * from auction where groupnum='$rs[groupnum]' order by stepnum desc limit 1"); $rsend=mysql_fetch_array($resend); mysql_query("update auction set bidstat = '2', winner='$rsend[userid]' where uid='$rs[uid]'"); } }//while }//if
?> <HTML> <HEAD> <TITLE> 낙찰 목록</TITLE> <style type="text/css"> <!-- a:link,a:visited,a:active { text-decoration : none; } a:hover { text-decoration : underline; color : red; } TABLE, TD, TR, TH { font-size : 10pt; } //--> </style>
</HEAD>
<BODY BGCOLOR="#FFFFFF"> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr align="center"> <td> <br> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" align=center>경매 낙찰 목록</td> </tr> </table> </td> </tr> </table> <table width="600" border="0" cellspacing="0" cellpadding="1" bgcolor="#BBBBBB"> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr align="center"> <td>낙찰번호</td> <td>제품명</td> <td>낙찰자</td> <td>낙찰금액</td> <td>낙찰일자</td> <td>거래상태</td> </tr> <? ########### 한 페이지당 출력할 게시물의 수 $num_per_page = 5;
########### 게시물 출력목록 하단에 링크를 걸 페이지의 개수 $page_per_block = 5;
########### 페이지 초기화 if(!$page) { $page = 1; }
$query = "SELECT uid,prod_uid, winner,dealstat FROM auction where bidstat ='2' ORDER BY enddate DESC";
$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; } } for($i = $first; $i <= $last; $i++) { $uid = mysql_result($result,$i,0); $prod_uid = mysql_result($result,$i,1); $winner = mysql_result($result,$i,2); $dealstat = mysql_result($result,$i,3); $rslast=""; $res = mysql_query("select * from bid where auction_uid='$uid' AND user_id = '$winner' order by signdate DESC"); if ($res) $rslast=mysql_fetch_array($res);
$rsprod=""; if ($prod_uid){ $resprod=mysql_query("select * from product where uid = '$prod_uid' "); if ($resprod) $rsprod=mysql_fetch_array($resprod); }
?> <tr align="center" bgcolor="#FFFFFF"> <td><?echo $uid;?><?if ($dealstat==0 && !strcmp($user_id,$winner) ){?><a href="auction_my_process.html?number=<?echo $uid;?>">[쇼핑팩]</a><?}?></td> <td><?echo $rsprod[name];?> </td> <td><?echo $winner;?></td> <td><?echo $rslast[myprice];?></td> <td><?echo $rslast[signdate];?></td> <td><? if ($rs[dealstat]==0)echo "쇼핑팩에 넣기전"; if ($rs[dealstat]==1)echo "쇼핑팩에 넣었음"; if ($rs[dealstat]==2)echo "배달중"; if ($rs[dealstat]==3)echo "거래완료"; if ($rs[dealstat]==4)echo "거래정지"; ?></td> </tr> <?}?> </table> </td> </tr> </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="600" 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 "] [ "; 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> <br> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td>※주의 : 낙찰일부터 5일내로 결제가 이루어지지 않으면, 낙찰이 자동 취소되며 불량 입찰자로 기제됩니다. <br> ※주문방법 : 쇼핑몰에서 제품을 주문하는 것과 같은 방법을 낙찰된 제품을 쇼핑팩에 넣고, 주문하시면 됩니다.</td> </tr> </table> <br> </td> </tr> </table> </BODY> </HTML>
7. 낙찰 경매제품 쇼핑팩에 담기 파일명 : auction_my_process.hrml <? session_start();
include "./user_function.html"; include "./dbconn.html";
$query = "UPDATE auction SET dealstat='1' WHERE uid = $number";
$result = mysql_query($query); if(!$result) { error("QUERY_ERROR"); exit; }
$query = "SELECT prod_uid,winner FROM auction WHERE uid = $number";
$result = mysql_query($query); if(!$result) { error("QUERY_ERROR"); exit; } $prod_uid = mysql_result($result, 0, 0); $winner = mysql_result($result, 0, 1);
$query = "SELECT myprice FROM bid WHERE auction_uid = $number AND user_id = '$winner' order by signdate DESC"; $result = mysql_query($query); if(!$result) { error("QUERY_ERROR"); exit; } $row1 = mysql_fetch_object($result);
$my_amount = 1; $query = "INSERT INTO temp_bag (product_uid,user_uid,price,amount) "; $query .= "VALUES ($prod_uid,'$user_uid','$row1->myprice',$my_amount)"; $result = mysql_query($query); if (!$result) { error("QUERY_ERROR"); exit; }
?> <script language="javascript"> <!-- window.alert("쇼핑팩에 담았습니다.\n장바구니보기에서 주문하시기 바랍니다."); //--> </script>
<? echo ("<meta http-equiv='Refresh' content='0; URL=./list_bag.html'>");
?>
|
[목차] |