홈페이지 메인에 많이 사용되는 리스트 클래스

· 19년 전 · 2695
<?

include 'Main.asp';

$objMain = new Main($dbconn); //dbconn커넥션을 인자로 전달합니다.

$arrData = $objMain->listBoard($board_name, $bid, $num, $str_length); //게시판 이름, 멀티보드일경우 인자값, 리스트에 출력될 게시물 수, 타이틀이 보여질 글자수


//에러 검출용 함수 사용시
$objMain->printErr();

for($i=0; i<count($arrData); i++){
echo $arrData[i][title]; //해당 필드를 나열해 주시면 됩니다.
}

/////////////////////////////
// - class.Main.php
/////////////////////////////

class Main
{
var $dbconn;

var $sql;
var $error_msg;

function Main($dbconn){
$this->dbconn = $dbconn;
}

function listBoard($board_name, $bid, $num=3, $str_length=50){
$this->sql = "select uid, title, doc, left(content,100) as content, (date_sub(curdate(), interval 5 DAY)<=wdate) as is_new
from $board_name
where bid=$bid
order by wdate desc limit $num";
$result = mysql_query($this->sql, $this->dbconn);
if($result){
$i=0;
while($row = mysql_fetch_object($result)){
$info[$i][uid] = $row->uid;
$info[$i][title] = stripslashes($row->title);
$info[$i][content] = stripslashes($row->content);
$info[$i][is_new] = $row->is_new;
$info[$i][doc] = $row->doc;

if(strlen($info[$i][title]) > $str_length)
$info[$i][title] = $this->ksubstr($info[$i][title],0,$str_length);

if($info[$i][is_new])
$info[$i][title] .= ' <img src="images/btn_new.gif" border="0">';
$i++;
}
return $info;
}
else {
$this->error_msg = mysql_error();
return false;
}
}

function printErr(){
echo "<br>SQL : ".$this->sql;
echo "<br>ERR : ".$this->error_msg;
}

// 한글용 ksubstr //
function ksubstr($string,$start,$length){
if($length>=strlen($string)) return $string;
$klen=$length-1;
while(ord($string[$klen]) & 0x80) $klen--;
return $add.substr($string,$start,$length-(($length+$klen+1)%2));
}
}
?><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
19년 전 조회 2,574
19년 전 조회 2,313
19년 전 조회 3,329
19년 전 조회 3,404
19년 전 조회 3,129
19년 전 조회 4,964
19년 전 조회 2,809
19년 전 조회 3,426
19년 전 조회 3,248
19년 전 조회 2,104
19년 전 조회 3,240
19년 전 조회 1,974
19년 전 조회 2,442
19년 전 조회 2,511
19년 전 조회 4,084
19년 전 조회 3,279
19년 전 조회 3,197
19년 전 조회 2,639
19년 전 조회 2,118
19년 전 조회 1,757
19년 전 조회 2,528
19년 전 조회 2,437
19년 전 조회 1,921
19년 전 조회 1,923
19년 전 조회 2,706
19년 전 조회 2,673
19년 전 조회 1,993
19년 전 조회 2,218
19년 전 조회 3,401
19년 전 조회 2,055
19년 전 조회 2,584
19년 전 조회 2,662
19년 전 조회 2,769
19년 전 조회 3,034
19년 전 조회 2,672
19년 전 조회 3,083
19년 전 조회 2,852
19년 전 조회 3,627
19년 전 조회 1,974
19년 전 조회 2,834
19년 전 조회 2,483
19년 전 조회 2,119
19년 전 조회 2,539
19년 전 조회 1,962
19년 전 조회 5,529
19년 전 조회 2,366
19년 전 조회 4,340
19년 전 조회 2,406
19년 전 조회 1,957
19년 전 조회 2,696
19년 전 조회 2,427
19년 전 조회 2,624
19년 전 조회 2,282
19년 전 조회 4,025
19년 전 조회 3,514
19년 전 조회 2,296
19년 전 조회 2,214
19년 전 조회 2,086
19년 전 조회 2,087
19년 전 조회 4,476
19년 전 조회 3,450
19년 전 조회 2,873
19년 전 조회 3,452
19년 전 조회 3,100
19년 전 조회 2,942
19년 전 조회 2,444
19년 전 조회 2,262
19년 전 조회 2,583
19년 전 조회 3,194
19년 전 조회 2,212
19년 전 조회 3,217
19년 전 조회 3,339
19년 전 조회 3,011
19년 전 조회 2,038
19년 전 조회 1,791
19년 전 조회 2,420
19년 전 조회 2,344
19년 전 조회 1,703
19년 전 조회 1,747
19년 전 조회 1,657
19년 전 조회 2,151
19년 전 조회 1,722
19년 전 조회 2,273
19년 전 조회 2,003
19년 전 조회 1,894
19년 전 조회 1,743
19년 전 조회 1,937
19년 전 조회 1,983
19년 전 조회 2,029
19년 전 조회 2,778
19년 전 조회 5,410
19년 전 조회 1,819
19년 전 조회 1,661
19년 전 조회 1,516
19년 전 조회 1,678
19년 전 조회 1,621
19년 전 조회 1,536
19년 전 조회 1,544
19년 전 조회 1,461
19년 전 조회 1,535