다시한번 질문드립니다. ( 메인 출석 노출 )

<?
include_once("./_common.php");
$g4['title'] = "출석부";
include_once("$g4[path]/head.sub.php");

$gr_id = "m03";

include_once("./head.php");

$colspan = "13";

echo "<script language=\"javascript\" src=\"$g4[path]/js/sideview.js\"></script>\n";



/*---------------------------------
## 달력 ##
---------------------------------*/

$datetime = $d;

if (!$datetime) {

$datetime = $g4['time_ymd'];

}

// 현재 시각 지정.
//$datetime = "2008-12-01";
//$datetime = $g4['time_ymd'];


// 현재 시각에서 월을 구한다.
$dateT1 = date("Y-m", strtotime($datetime));

// 현재 월의 1일의 요일 값을 구한다.
$dateT2 = date("w", strtotime($dateT1."-01"));

// 현재 월의 1일에서 요일 값을 뺀다.
$dateT3 = date("Y-m-d", strtotime($dateT1."-01") - (86400 * $dateT2));


// 현재 월의 1일에서 31일을 더한다.
$dateN1 = date("Y-m-d", strtotime($dateT1."-01") + (86400 * 31));

// 다음 달의 월을 구한다.
$dateN2 = date("Y-m", strtotime($dateN1));

// 다음 달 1일을 구한다.
$dateN3 = date("Y-m-d", strtotime($dateN2."-01"));

// 다음 달 1일에서 1일을 뺀다. 그럼 이번 달 마지막일
$dateN4 = date("d", strtotime($dateN3) - (86400 * 1));

// 6 뺀다. 현재 달 마지막 일 요일을 구해서.
$dateN5 = 6 - date("w", strtotime($dateT1."-".$dateN4));


// 현재 월의 1일에서 1일을 뺀다.
$dateP1 = date("Y-m-d", strtotime($dateT1."-01") - (86400 * 1));


/*---------------------------------
## 리스트 ##
---------------------------------*/

// 날짜가 있다면.
if ($d) {

$sql_common = "substring(datetime,1,10) = '$datetime'";

} else {
// 오늘

$sql_common = "substring(datetime,1,10) = '$g4[time_ymd]'";

}
?>
<style type="text/css">
ul, li {list-style:none outside;}
A {text-decoration:none;}


/* date */
#date_layer {text-align:left;;}

#date_layer #box {width:120px;}
#date_layer #box .top {width:20px; float:left;}
#date_layer #box .day {width:80px; float:left;}

#date_layer .w {font-weight:bold; line-height:20px; color:#333333; font-size:15px; font-family:굴림,돋움;}
#date_layer .title {color:#565656; font-size:12px; font-family:굴림,돋움; padding:0 0 0 1px;}

#date_layer .sun1 {color:#ff0000; font-size:12px; font-family:굴림,돋움;}
#date_layer .sat1 {color:#0000ff; font-size:12px; font-family:굴림,돋움;}
#date_layer .day1 {color:#333333; font-size:12px; font-family:굴림,돋움;}

#date_layer .sun2 {font-weight:bold; line-height:20px; color:#ff0000; font-size:15px; font-family:굴림,돋움;}
#date_layer .sat2 {font-weight:bold; line-height:20px; color:#0000ff; font-size:15px; font-family:굴림,돋움;}
#date_layer .day2 {font-weight:bold; line-height:20px; color:#333333; font-size:15px; font-family:굴림,돋움;}

#date_layer .sun3 {color:#ffbebe; font-size:11px; font-family:굴림,돋움;}
#date_layer .sat3 {color:#b8b8ff; font-size:11px; font-family:굴림,돋움;}
#date_layer .day3 {color:#999999; font-size:11px; font-family:굴림,돋움;}

#date_layer .dot {color:#000000; font-size:12px; font-family:굴림,돋움;}

#date_layer .check {color:#126420; font-size:11px; font-family:굴림,돋움;}
#date_layer .check2 {color:#999999; font-size:11px; font-family:굴림,돋움;}


/* list */
#list_layer .input {width:300px; height:21px; background-color:#f3f3f3; border:0px; padding:5px 2px 2px 2px; font-weight:bold; color:#333333; font-family:굴림,돋움; font-size:13px;}

#list_layer .msg {padding:5px 0 0 3px; float:left;}
#list_layer .sub {float:left;}
#list_layer .submit {padding:3px 0 0 5px; float:left;}

#list_layer #info li {line-height:18px; color:#898989; font-family:굴림,돋움; font-size:11px;}

#list_layer .title {font-weight:bold; color:#333333; font-family:굴림,돋움; font-size:12px;}
#list_layer .list {line-height:20px; color:#898989; font-family:굴림,돋움; font-size:11px;}

#list_layer .no {line-height:25px; font-size:12px; color:#898989;}

#list_layer .bgcolor0 {background-color:#ffffff;}
#list_layer .bgcolor1 {background-color:#f1f1f1;}
#list_layer .bgcolor2 {background-color:#ffffff;}
</style>



<div id="BoardText">

<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td valign="top"><!-- left start //-->
<div id="date_layer">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:10px; border:1px solid #e4e4e4;">
<tr height="30">
<td colspan="7" align="center">
<div id="box">
<li class="top"><a href="?d=<?=$dateP1?>&mode=<?=$mode?>" class="dot">◀</a></li>
<li class="day"><span class="w"><?=$dateT1?></span></li>
<li class="top"><a href="?d=<?=$dateN3?>&mode=<?=$mode?>" class="dot">▶</a></li>
</div></td>
</tr>
<tr><td colspan="7" height="1" bgcolor="#e4e4e4"></td></tr>
<tr height='30'>
<td width="55" align="center" class="title">일</td>
<td width="55" align="center" class="title">월</td>
<td width="55" align="center" class="title">화</td>
<td width="55" align="center" class="title">수</td>
<td width="55" align="center" class="title">목</td>
<td width="55" align="center" class="title">금</td>
<td width="55" align="center" class="title">토</td>
</tr>
<tr height='55'>
<?
// 7셀만 출력. 다음 셀로 자동 변경.
$mod = "7";

// 돌리고 돌리고~ 마지막 일에서 이번 달 1일의 요일 값 만큼 더한다.
for ($i=0; $i<($dateN4 + $dateT2 + $dateN5); $i++) {

// 6일 뺀 날짜부터 돌린다.
$dateT4 = date("Y-m-d", strtotime($dateT3) + (86400 * $i));

// 해당 날짜의 요일을 구한다.
$dateT5 = date("w", strtotime($dateT3) + (86400 * $i));

if ($i && $i%$mod == '0') {

echo "</tr>\n<tr height='55'>\n";

}

// 일요일 제외
if ($dateT5 != '0') {

$dateLine = "border-left:1px solid #e4e4e4;";

} else {

$dateLine = "";

}

echo "<td align='center' style='" . $dateLine . " border-top:1px solid #e4e4e4;'>";

// 현재 월과 돌린 월이 일치할 때만.
if ($dateT1 == substr($dateT4,0,7)) {

// 찍은 날짜면
if ($datetime == $dateT4) {

// 0은 일요일.
if ($dateT5 == '0') {

// 빨강색
$dateClassName = "sun2";

}
// 6은 토요일
else if ($dateT5 == '6') {

// 파랑색
$dateClassName = "sat2";

} else {

// 기타
$dateClassName = "day2";

}

}

// 오늘 날짜면
else if ($g4['time_ymd'] == $dateT4) {

// 0은 일요일.
if ($dateT5 == '0') {

// 빨강색
$dateClassName = "sun2";

}
// 6은 토요일
else if ($dateT5 == '6') {

// 파랑색
$dateClassName = "sat2";

} else {

// 기타
$dateClassName = "day2";

}

} else {

// 0은 일요일.
if ($dateT5 == '0') {

// 빨강색
$dateClassName = "sun1";

}
// 6은 토요일
else if ($dateT5 == '6') {

// 파랑색
$dateClassName = "sat1";

} else {

// 기타
$dateClassName = "day1";

}

}

echo "<div style='height:20px;'>";
echo "<a href=\"javascript:dateGo('".$dateT4."')\">";
echo "<span class='" . $dateClassName . "'>";
echo substr($dateT4,8,2);
echo "</span>";
echo "</a>";
echo "</div>";


// 출석했나?
$sql = " select id from $p4[attendance_table] where mb_id = '$member[mb_id]' and substring(datetime,1,10) = '$dateT4' ";
$check = sql_fetch($sql);

// 출석
if ($check['id']) {

echo "<div style='margin-top:3px;'>";
echo "<span class='check'>[O]</apan>";
echo "</div>";

} else {

echo "<div style='margin-top:3px;'>";
echo "<span class='check2'>[X]</apan>";
echo "</div>";

}

} else {
// 다른 달

// 0은 일요일.
if ($dateT5 == '0') {

// 빨강색
$dateClassName = "sun3";

}
// 6은 토요일
else if ($dateT5 == '6') {

// 파랑색
$dateClassName = "sat3";

} else {

// 기타
$dateClassName = "day3";

}

//echo "<a href=\"javascript:dateGo('".substr($dateT4,5,5)."')\">";
echo "<span class='" . $dateClassName . "'>";
echo substr($dateT4,5,5);
echo "</span>";
//echo "</a>";

}

echo "</td>\n";

}

// 나머지 셀을 채운다.
$cnt = $i%$mod;
if ($cnt) {

for ($i=$cnt; $i<$mod; $i++) {

echo "<td> </td>\n";

}

}
?>
</tr>
</table>
</div>

<script type="text/javascript">
function dateGo(day)
{

document.location.href = "?d="+day;

}
</script>
<!-- left end //-->
</td>
</tr>
<tr>
<td valign="top">
<!-- right start //-->
<div id="list_layer">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr height="30">
<td><b>출석체크하고 포인트 받자!!</b></td>
</tr>
<tr>
<td style="height:32px; border:1px solid #cccccc;">
<form name="fattendance" method="post" action="javascript:fattendance_submit(document.fattendance);" style="margin:0px;">
<div id="title">

<li class="msg">한마디 : </li>

<li class="sub"><input type="text" id="subject" name="subject" class="input" value="한마디를 입력해 주세요." onmouseover="if(!this.value || this.value == '한마디를 입력해 주세요.')this.value='';"></li>

<li class="submit"><input type="image" src="img/btn_ok.gif" border="0"></li>

</div>
</form>

<script type="text/javascript">
function fattendance_submit(f)
{

var ChkSubject = document.getElementById("subject").value;

if (!ChkSubject || ChkSubject == '한마디를 입력해 주세요.') {

alert("한마디를 입력하세요.");
return;

}

f.action = "./update.php";
f.submit();

}
</script>
</td>
</tr>
<tr><td height="10"></td></tr>
<tr>
<td height="50">
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td width="5"></td>
<td width="50"><img src="img/image.gif" align="absmiddle"></td>
<td width="20"></td>
<td>
<div id="info">

<li>→ 출석시간 : <?=date("a h시 i분 s초", strtotime($att['start_time']))?> ~ <?=date("a h시 i분 s초", strtotime($att['end_time']))?></li>

<li>→ 출석포인트 : <?=number_format($att['today_point'])?> 점 (개근상 : <?=$att['day']?>일 마다 <?=number_format($att['day_point'])?> 점)</li>

<li>→ 1등 포인트 : <?=number_format($att['first_point'])?> 점</li>

</div>
</td>
</tr>
</table></td>
</tr>
<tr><td height="10"></td></tr>
<tr>
<td height="20"><span style="font-family:굴림,돋움; font-size:12px; color:#898989;">[<?=$datetime?>]</span></td>
</tr>
<tr><td height="5"></td></tr>
<tr>
<td width="100%">
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" valign="top">
<tr><td colspan="<?=$colspan?>" height="3" bgcolor="#F2F2F2"></td></tr>
<tr><td colspan="<?=$colspan?>" height="1" bgcolor="#D9D9D9"></td></tr>
<tr height="30">
<td width="50" align="center" class="title">등수</td>
<td width="1"><img src="img/line_01.gif" width="1" height="13"></td>
<td width="80" align="center" class="title">출석시간</td>
<td width="1"><img src="img/line_01.gif" width="1" height="13"></td>
<td width="110" align="center" class="title">닉네임</td>
<td width="1"><img src="img/line_01.gif" width="1" height="13"></td>
<td align="center" class="title">한마디</td>
<td width="1"><img src="img/line_01.gif" width="1" height="13"></td>
<td width="60" align="center" class="title">접속중</td>
<td width="1"><img src="img/line_01.gif" width="1" height="13"></td>
<td width="60" align="center" class="title">포인트</td>
<td width="1"><img src="img/line_01.gif" width="1" height="13"></td>
<td width="60" align="center" class="title">개근</td>
</tr>
<tr><td colspan="<?=$colspan?>" height="1" bgcolor="#D9D9D9"></td></tr>
<tr><td colspan="<?=$colspan?>" height="3" bgcolor="#F2F2F2"></td></tr>
<?
// 출석 테이블 연결
$sql = " select * from $p4[attendance_table] where $sql_common order by datetime asc, day desc ";
$result = sql_query($sql);
for ($i=0; $data=sql_fetch_array($result); $i++) {

// 접속자테이블 연결
$sql = " select mb_id from $g4[login_table] where mb_id = '$data[mb_id]' ";
$ing = sql_fetch($sql);

// 접속상태
if ($ing['mb_id']) {

$on = "접속중";

} else {

$on = "";

}

// 회원 테이블 연결
$check = get_member($data['mb_id']);

// 닉네임
$name = get_sideview($check['mb_id'], $check['mb_nick'], $check['mb_email'], $check['mb_homepage']);

// 랭킹
$rank = $i + 1;

/*
// 색상
if ($member['mb_id'] == $data['mb_id']) {

$list = "2";

} else {

$list = ($i%2);

}
*/

$list = ($i%2);
?>
<tr height="30">
<td align="center" class="bgcolor<?=$list?> list"><?=$rank?> 등</td>
<td></td>
<td align="center" class="bgcolor<?=$list?> list"><?=date("a h:i:s", strtotime($data['datetime']))?><?//=substr($data['datetime'],10,16);?></td>
<td></td>
<td align="center" class="bgcolor<?=$list?> list"><?=$name?></td>
<td></td>
<td style="padding:0 0 0 20px;" class="bgcolor<?=$list?> list"><?=get_text($data['subject'])?></td>
<td></td>
<td align="center" class="bgcolor<?=$list?> list"><?=$on?></td>
<td></td>
<td align="right" style="padding:0 5 0 0px;" class="bgcolor<?=$list?> list"><?=number_format($data['point']);?> 점</td>
<td></td>
<td align="center" class="bgcolor<?=$list?> list"><?=$data['day']?> 일째</td>
</tr>
<tr><td bgcolor="#EEEEEE" colspan="<?=$colspan?>" height="1"></td></tr>
<? } ?>
<? if (!$i) { ?>
<tr><td height="100" colspan="<?=$colspan?>" align="center"><span class="no">출석한 사람이 없습니다.<br>출석시간 : <?=date("a h시 i분 s초", strtotime($att['start_time']))?> ~ <?=date("a h시 i분 s초", strtotime($att['end_time']))?></span></td></tr>
<tr><td colspan="<?=$colspan?>" height="1" bgcolor="#eeeeee"></td></tr>
<? } ?>
</table></td>
</tr>
</table>
</div>
<!-- right end //--></td>
</tr>
</table>

</div>

<br>

<?
include_once("./tail.php");
include_once("$g4[path]/tail.sub.php");
?>



-----attendance.php 파일이구요...


이 중에서 오늘의 출석 순위를 1위부터 5위까지 메인에 노출하려고 하는데..

도저히 방법을 모르겠네요..쿼리에 좀 짧아서요..
|

댓글 7개

sql에 limit 를 사용해보세요
쿼리구문에 출석날짜와 현재날짜를 비교한 후 출석순위가 높은 기준 필드로 내림차순 정렬하고 limit으로 0, 4 해서 5개 뽑으면 되겠네용 ~(1, 5 였던가.. --a 가물가물 ㅎㅎ)

현재 디비 구조도를 잘 모르니,, 이렇게 한글로나마 적어봅니당 ~
답변 감사합니다~ 제가.. 쿼리 경험이 거의 전무하다 시피해서요..

조금더 자세히 부탁드려도 될까요..

현재 출석부 페이지는 잘 구동이 되고 있구요..

순위도 잘 나오고 있는데 그걸 메인으로 빼는걸 못해서 몇일간 고생하고 있습니다..ㅠ
현재 만들고 계신 페이지 주소를 알 수 있을까용?

어떤 형태인지 좀 보고 싶네용 ㅎㅎ;
아... 현재 로컬로 작업중이라서요...허허

음..어떤 형태인지를 설명해드리면 좀 복잡할까요??

저위에 있는 써놓은 소스가 localhost/attendance/attendance.php 에 있구요..

이곳에 접속하면.. 출석리스트가 쭉 나옵니다..

1위부터 50위까지인가 나오는데...

메인에 추출해서 5위까지 보여줄 생각이구요~
오늘의 순위 1-50위가 나오는건가요?

총 순위에서 1-50위가 나올듯 해서용,, 아닌가 --a ㅎㅎ

오늘의 순위 1-50위가 나오는 거라면

// 출석 테이블 연결
$sql = " select * from $p4[attendance_table] where $sql_common order by datetime asc, day desc ";

부분을

// 출석 테이블 연결
$sql = " select * from $p4[attendance_table] where $sql_common order by datetime asc, day desc limit 0, 4"; 를 붙여주면 될것 같은데,, (1,5 였나,, --a ㅎㅎ)
그니깐... 메인화면에 최신글 형태로 빼는 법을 여쭌건데..ㅠ

어렵네요 ..ㅠ
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

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

+
제목 글쓴이 날짜 조회
14년 전 조회 993
14년 전 조회 1,587
14년 전 조회 1,033
14년 전 조회 2,183
14년 전 조회 1,091
14년 전 조회 1,569
14년 전 조회 1,172
14년 전 조회 984
14년 전 조회 1,889
14년 전 조회 1,596
14년 전 조회 1,733
14년 전 조회 1,538
14년 전 조회 1,658
14년 전 조회 1,592
14년 전 조회 1,575
14년 전 조회 3,448
14년 전 조회 1,674
14년 전 조회 1,045
14년 전 조회 888
14년 전 조회 1,730