| 
| ÆäÀÌ¡ - ´ÙÁß Á¤·Ä : ¿À¸§, ³»¸², º¸Åë |  |  
|  |  |    | 14³â Àü |  | 
| Àú´Â ´ëºÎºÐÀÇ ¼Ò½ºµéÀº ´Ü¼øÈ÷ ÇÔ¼ö·Î¸¸ Á¦ÀÛÇÏ¿© ¾²°í ÀÖÁö¸¸, ÆäÀÌ¡±â¹ýó·³ ¿©·¯°¡Áö ÇÔ¼ö¸¦ µ¿½Ã¿¡ »ç¿ëÇØ¾ß µÉ °æ¿ì¿¡´Â ¾Æ·¡Ã³·³
 Ŭ·¡½º¸¦ µµÀÔÇϰí ÀÖ½À´Ï´Ù.
 
 ÀÌ Å¬·¡½ºÀÇ ÀåÁ¡À̶ó°í ÇÑ´Ù¸é, Á¤·Ä ±â´ÉÀÌ Àß µÇ¾î ÀÖ´Ù´Â °ÍÀÔ´Ï´Ù.
 ÈçÈ÷µé ŸÀÌÆ²À» ´·¶À»¶§, ¿À¸§, ³»¸²Â÷¼øÀ¸·Î Á¤·Ä µÇ´Â ±â´ÉÀ» ±¸ÇöÇÏ´Â ³»¿ëÀº
 CSSȯ°æ¿¡¼´Â ´ëü·Î ±¸ÇöÀÌ ÀߵǾî ÀÖÁö¸¸, À¥¿¡¼´Â ¸¹ÀÌ Ã£¾Æ º¸±â Èûµç
 ³»¿ëÀÎ°Í °°½À´Ï´Ù.
 
 ¾Æ·¡´Â »ç¿ë¿¹Á¦ÀÔ´Ï´Ù.
 
 <?
 /////////////////////////== µ¥ÀÌŸó¸® ÆäÀÌÁöÀ̸ç, ¼±¾ðºÎ¿¡ ¿Ã·ÁÁÝ´Ï´Ù.
 // ÆäÀÌÁö ÃʱⰪ »ý¼º
 $nowpg = ($nowpg) ? $nowpg : 1;
 
 // ÀνºÅÏÆ® »ý¼º
 $sql = new ListManager();
 
 // ¿É¼Ç
 // ÇÑȸ鿡 º¸¿©ÁÙ ÁÙ¼ö ¹× ÇÑ È¸é¿¡ º¸¿©ÁÙ ÆäÀÌÁö ¹× ÀÌÀü, ´ÙÀ½, óÀ½, ³¡ ÅÂ±× ¼ÂÆÃ
 $sql->page_setting(15, 10, "<img src='./img/btn_page_first.gif' border='0' align='absmiddle'>", "  ÀÌÀü", "´ÙÀ½  ", "<img src='./img/btn_page_last.gif' border='0' align='absmiddle'>");
 
 // ¿É¼Ç
 // Á¤·ÄÇÏ°Ú´Ù°í ¸¾ ¸Ô¾ú´Ù¸é »ç¿ëÇØ ÁÖ¼¼¿ä.
 // Â÷·Ê´ë·Î ¹öư ´·¶À»¶§ »ö, ¾È´·¶À»¶§ »ö, ³»¸²Â÷¼ø, ¿À¸¥Â÷¼ø ¸ð¾çÀÔ´Ï´Ù.
 $sql->sort_setting("#FF0000", "#6699CC", "¡â", "¡ä")
 
 // µ¥ÀÌŸ °Ë»ö½Ã »ç¿ëµÇ´Â ¿¹´Â ¾Æ·¡¿Í °°À¸¸ç, ±âº»ÀûÀ¸·Î ¾Æ·¡ Ç׸ñ¸¸ ¾²ÀÌ°Ô µË´Ï´Ù.
 //
 // $boardtable : Å×À̺í¸í (Á¶Àνà tablea, tableb ¿Í °°Àº½ÄÀ¸·Î ³ª¿)
 // $nowpg : »ó¼ö°ª (º¯¼ö ¹Ù²ÙÁö ¸¶¼¼¿ë)
 // BF_delete='N' : ±âº»Á¶°Ç (°Ë»öÀ» ¾ÈÇÑ »óÅ¿¡¼ÀÇ Á¶°ÇÀýÀ» ÀÔ·ÂÇØ ÁÝ´Ï´Ù.)
 // $findquery : °Ë»ö½Ã »ç¿ë (Á¶°Ç¿¡ µû¶ó º¯ÇÏ´Â Á¶°ÇÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä. ¿¹) BF_name like '%°Ë»ö¾î%')
 // BF_index desc : Á¤·Ä ¹æ½Ä (´ÙÁßÀ¸·Î °¡´ÉÇÕ´Ï´Ù. ¿¹) BF_index desc, BF_no asc)
 $sql->ListDatabase($boardtable, $nowpg, "*", "BF_delete='N'", $findquery, "BF_index desc");
 
 // °Ë»öµÈ °ªÀ» ¹è¿·Î ¹Þ¾Æ¿À´Â 󸮰úÁ¤ (2Â÷¿ø¹è¿·Î ¹Þ¾ÆÁü, ¹Þ¾Æ¿À´ÂÇü½Ä- $rows[À妽º][DBÇʵå¸í])
 $rows = $sql->data();
 
 // ¿É¼Ç : Ãâ·Â½Ã ¹Ù·Î »Ñ·ÁÁ൵ µÊ
 // ÀÌÀü, ´ÙÀ½, óÀ½, ³¡, ÆäÀÌÁö Á¤º¸¸¦ °¡Áö°í ÀÖÀ½ (°³ÀÎÀ¸·Î ¾µ °æ¿ì ¾Æ·¡¿¡¼ ¸Þ¼Òµå¸¦ Á÷Á¢ È£Ãâ ¿¹) $sql->pg_next())
 $page = $sql->page();
 
 // ¿É¼Ç : Ãâ·Â½Ã ¹Ù·Î »Ñ·ÁÁ൵ µÊ
 // ±âº»Á¶°ÇÀ¸·Î ãÀº °Ë»ö ¶óÀμö
 $total = intval($sql->total());
 
 // ¿É¼Ç : Ãâ·Â½Ã ¹Ù·Î »Ñ·ÁÁ൵ µÊ
 // °Ë»öÁ¶°ÇÀ¸·Î ãÀº °Ë»ö ¶óÀμö
 $find = intval($sql->find());
 
 // ¿É¼Ç
 // ¸¸ÀÏ ÇöÀç ÆäÀÌÁö°¡ 1º¸´Ù Å©°Ô °¡ Àִµ¥ µ¥ÀÌŸ°¡ ¾ø´Ù¸é 1ÆäÀÌÁö·Î µ¹·Á Áà¾ß °ÚÁÒ?
 if($nowpg != 1 && count($rows)==0) {
 $nowpg = $sql->page_all;
 tomove(url_clear("$_SERVER[REQUEST_URI]&nowpg=$nowpg"));
 }
 
 /////////////////////////== Ãâ·ÂÆäÀÌÁö
 ?>
 <table>
 <tr>
 <td>NO</td>
 <!-- Â÷·Ê´ë·Î ŸÀÌÆ²¸í, Á¤·ÄÇÒ Çʵå, ÃʱâÁ¤·ÄŸÀÔ ÀÔ´Ï´Ù. -->
 <td><?=$sql->sortting("À̸§º°Á¤·Ä", "BF_name", "asc")?></td>
 <td><?=$sql->sortting("µî·Ï½Ã°£º°Á¤·Ä", "BF_insert_time", "desc")?></td>
 <td></td>
 </tr>
 
 <? for($i=0, $count=count($rows); $i<$count; $i++) { ?>
 <tr>
 <!-- _facing Çʵ带 ÁÖ°Ô µÇ¸é, Á¤ÇØÁø ±ÔÄ¢¿¡ ÀÇÇØ À妽º ¼ø¼·Î Á¤·ÄÇØ ÁØ´Ù. -->
 <td><?=$rows[$i][_facing]?></td>
 <td><?=$rows[$i][BF_name]?></td>
 <td><?=$rows[$i][BF_insert_time]?></td>
 </tr>
 <tr align="center">
 <td colspan="2"><?=$page?></td>
 </tr>
 
 <? } if($count == 0) { ?>
 <tr align="center">
 <td colspan="2"><font color="red">µ¥ÀÌŸ°¡ °Ë»öµÇÁö ¾Ê¾Ò½À´Ï´Ù.</font></td>
 </tr>
 <? } ?>
 
 </table>
 
 
 
 <?
 /************************************************************************************
 ¾Æ·¡ºÎÅÍ´Â ½ÇÁ¦·Î »ç¿ëÇÒ¼ö ÀÖ°Ô ÇÏ´Â ¼Ò½ºÀÔ´Ï´Ù
 *************************************************************************************/
 class ListManager {
 var $ords='', $url='', $urlqry='', $href_first='', $href_next='', $query_str='';
 var $nowpg=1, $line_num=10, $page_num=10, $find='', $total=0, $page_first=0, $page_last=0, $page_all;
 var $button_first='[óÀ½]', $button_pre='[ÀÌÀü]', $button_next='[´ÙÀ½]', $button_last='[³¡]';
 var $onbg='#FF0000', $offbg='#6699CC', $str_asc='¡â', $str_desc='¡ä';
 
 function ListDatabase($tbname, $nowpg, $flds="*", $whrs="", $fndqry="", $ords="", $grps="") {
 global $_SERVER, $_GET;
 
 $geturlkey = &$_GET[sortfldkey];
 $geturlarrow = &$_GET[sortfldarrow];
 $arykey = explode(",", $geturlkey);
 $aryarrow = explode(",", $geturlarrow);
 $cnt=0; while($cnt<count($arykey)) {
 if($arykey[$cnt] && $aryarrow[$cnt]) {
 $ords_tmp[] = "$arykey[$cnt] $aryarrow[$cnt]";
 }
 $cnt++;
 }
 if($ords) $ords_tmp[] = $ords;
 if(count($ords_tmp)) { $ords = implode(",", $ords_tmp); }
 if($ords) $ords = "order by $ords";
 
 $cnt_fld="count(*)";
 $this->nowpg = $nowpg;
 $this->ords = $ords;
 $this->url = $_SERVER[PHP_SELF];
 $this->urlqry = $_SERVER[QUERY_STRING];
 
 if($whrs) { $whrs = "where $whrs"; }
 if($grps) {
 $cnt_fld = "count(distinct $grps)";
 $grps = "group by $grps";
 }
 if($fndqry) { $fndqry = "and $fndqry"; }
 if($this->urlqry) { $this->urlqry = "$this->urlqry&"; }
 
 if($this->nowpg <= 0) { $this->nowpg = 1; }
 
 //°Ë»öµÈÄ«¿îÆ®
 $query = "select $cnt_fld cnt from $tbname $whrs $fndqry";
 $res = query($query);
 $row = mysql_fetch_row($res);
 $this->find = $row[0];
 
 //Àüüī¿îÆ®
 $query = "select $cnt_fld cnt from $tbname $whrs";
 $res = query($query);
 $row = mysql_fetch_row($res);
 $this->total = $row[0];
 
 //ÇöÀ罺ÅÜ
 $sp_now = ceil($this->nowpg / $this->page_num);
 //Àüü½ºÅÜ
 $sp_all = ceil($this->find / ($this->page_num*$this->line_num));
 //ÀüüÆäÀÌÁö
 $this->page_all = ceil($this->find / $this->line_num);
 //ÇöÀ罺ÅÜÀÇ Ã¹ÆäÀÌÁö
 $this->page_first = 1 + ($sp_now-1) * $this->page_num;
 //ÇöÀ罺ÅÜÀÇ ³¡ÆäÀÌÁö
 $this->page_last  = $this->page_first + $this->page_num - 1; if($this->page_last > $this->page_all) $this->page_last = $this->page_all;
 
 //óÀ½¹öư
 if($this->nowpg > 1) { $this->href_first = $this->urlqry . "nowpg=1"; }
 //ÀÌÀü¹öư
 if($sp_now > 1) { $this->href_pre = $this->urlqry . "nowpg=" . ($this->page_first - $this->page_num); }
 //´ÙÀ½¹öư
 if($sp_now * $this->line_num * $this->page_num < $this->find) { $this->href_next = $this->urlqry . "nowpg=" . ($this->page_last + 1); }
 //¸¶Áö¸·¹öư
 if($this->page_all != $this->nowpg) { $this->href_last = $this->urlqry . "nowpg=$this->page_all"; }
 
 //µ¥ÀÌŸ °Ë»ö
 $limit_first = ($this->nowpg - 1) * $this->line_num;
 
 $this->query_str = "select $flds from $tbname $whrs $fndqry $grps $this->ords limit $limit_first, $this->line_num";
 $query = &$this->query_str;
 $res = query($query);
 $i = 0;
 while($row = mysql_fetch_assoc($res)) {
 $row["_facing"] = $this->total - ($limit_first + 1) - ($i - 1);
 $this->view[] = $row;
 $i++;
 }
 }
 
 //ÆäÀÌÁö¼³Á¤ ¼ÂÆÃ
 function page_setting($line=10, $page=10, $first="[óÀ½]", $pre="[ÀÌÀü]", $next="[´ÙÀ½]", $last="[³¡]") {
 $this->line_num   = $line;
 $this->page_num   = $page;
 $this->button_first = $first;
 $this->button_pre   = $pre;
 $this->button_next  = $next;
 $this->button_last  = $last;
 }
 
 //Á¤·Ä¼³Á¤ ¼ÂÆÃ
 function sort_setting($onbg="#FF0000", $offbg="#6699CC", $str_asc="¡â", $str_desc="¡ä") {
 $this->onbg = $onbg;
 $this->offbg   = $offbg;
 $this->str_asc  = $str_asc;
 $this->str_desc  = $str_desc;
 }
 
 //Á¤·Ä
 function sortting($subject, $sortfld, $base_arrow="asc") {
 global $_SERVER, $_GET;
 
 $geturlkey = &$_GET[sortfldkey];
 $geturlarrow = &$_GET[sortfldarrow];
 $geturlflag = &$_GET[sortfldflag];
 
 $arykey = explode(",", $geturlkey);
 $aryarrow = explode(",", $geturlarrow);
 $arrflag = explode(",", $geturlflag);
 
 $arrow_ary_img = array("asc"=>$this->str_asc, "desc"=>$this->str_desc);
 $arrow_ary_rep = array("asc"=>"desc", "desc"=>"asc");
 
 //ÃʱⰪȣÃâ
 $cnt=0; while($cnt<count($arykey)) {
 if($sortfld == $arykey[$cnt]) {
 $tmp_urlkey = $arykey[$cnt];
 $tmp_urlarrow = $arrow_ary_rep[$aryarrow[$cnt]];
 $tmp_urlflag = $arrflag[$cnt];
 $arrow = $arrow_ary_img[$aryarrow[$cnt]];
 }
 else if($arykey[$cnt] && $aryarrow[$cnt]) {
 $urlkey[$arykey[$cnt]] = $arykey[$cnt];
 $urlarrow[$arykey[$cnt]] = $aryarrow[$cnt];
 $urlflag[$arykey[$cnt]] = $arrflag[$cnt];
 }
 $cnt++;
 }
 $urlkey[$sortfld] = $tmp_urlkey;
 $urlarrow[$sortfld] = $tmp_urlarrow;
 $urlflag[$sortfld] = $tmp_urlflag;
 
 //ÃʱⰪ¼ÂÆÃ
 if(!$urlkey[$sortfld] && $urlflag[$sortfld] != 2) {
 $urlkey[$sortfld] = $sortfld;
 $urlarrow[$sortfld] = $base_arrow;
 $urlflag[$sortfld] = 0;
 }
 
 switch($urlflag[$sortfld]) {
 case 1:
 $urlflag[$sortfld]++;
 break;
 
 case 2:
 unset($urlkey[$sortfld]);
 unset($urlarrow[$sortfld]);
 unset($urlflag[$sortfld]);
 break;
 
 default :
 $urlflag[$sortfld]++;
 unset($arrow);
 break;
 }
 
 if(count($urlkey)) { $sortfldkey = implode(",", $urlkey); }
 if(count($urlarrow)) { $sortfldarrow = implode(",", $urlarrow); }
 if(count($urlflag)) { $sortfldflag = implode(",", $urlflag); }
 
 | 
 |  
|  ̵̧ : 782 | ̵̧
¸ñ·Ï |  |