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

· 19년 전 · 2589
<?

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,445
19년 전 조회 2,205
19년 전 조회 3,230
19년 전 조회 3,290
19년 전 조회 3,026
19년 전 조회 4,861
19년 전 조회 2,691
19년 전 조회 3,303
19년 전 조회 3,132
19년 전 조회 1,982
19년 전 조회 3,123
19년 전 조회 1,869
19년 전 조회 2,333
19년 전 조회 2,404
19년 전 조회 3,984
19년 전 조회 3,172
19년 전 조회 3,096
19년 전 조회 2,539
19년 전 조회 1,999
19년 전 조회 1,641
19년 전 조회 2,412
19년 전 조회 2,330
19년 전 조회 1,820
19년 전 조회 1,816
19년 전 조회 2,603
19년 전 조회 2,579
19년 전 조회 1,877
19년 전 조회 2,110
19년 전 조회 3,295
19년 전 조회 1,950
19년 전 조회 2,495
19년 전 조회 2,568
19년 전 조회 2,660
19년 전 조회 2,937
19년 전 조회 2,563
19년 전 조회 2,978
19년 전 조회 2,760
19년 전 조회 3,512
19년 전 조회 1,871
19년 전 조회 2,732
19년 전 조회 2,371
19년 전 조회 2,020
19년 전 조회 2,428
19년 전 조회 1,873
19년 전 조회 5,440
19년 전 조회 2,260
19년 전 조회 4,244
19년 전 조회 2,297
19년 전 조회 1,848
19년 전 조회 2,590
19년 전 조회 2,333
19년 전 조회 2,527
19년 전 조회 2,170
19년 전 조회 3,911
19년 전 조회 3,415
19년 전 조회 2,199
19년 전 조회 2,107
19년 전 조회 1,975
19년 전 조회 1,993
19년 전 조회 4,373
19년 전 조회 3,352
19년 전 조회 2,775
19년 전 조회 3,351
19년 전 조회 3,002
19년 전 조회 2,841
19년 전 조회 2,343
19년 전 조회 2,163
19년 전 조회 2,487
19년 전 조회 3,099
19년 전 조회 2,125
19년 전 조회 3,116
19년 전 조회 3,250
19년 전 조회 2,921
19년 전 조회 1,940
19년 전 조회 1,702
19년 전 조회 2,318
19년 전 조회 2,255
19년 전 조회 1,626
19년 전 조회 1,660
19년 전 조회 1,562
19년 전 조회 2,073
19년 전 조회 1,620
19년 전 조회 2,181
19년 전 조회 1,913
19년 전 조회 1,806
19년 전 조회 1,650
19년 전 조회 1,843
19년 전 조회 1,887
19년 전 조회 1,945
19년 전 조회 2,693
19년 전 조회 5,319
19년 전 조회 1,722
19년 전 조회 1,569
19년 전 조회 1,435
19년 전 조회 1,592
19년 전 조회 1,527
19년 전 조회 1,447
19년 전 조회 1,452
19년 전 조회 1,374
19년 전 조회 1,443
🐛 버그신고