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

· 19년 전 · 2586
<?

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,442
19년 전 조회 2,201
19년 전 조회 3,227
19년 전 조회 3,286
19년 전 조회 3,023
19년 전 조회 4,857
19년 전 조회 2,686
19년 전 조회 3,299
19년 전 조회 3,131
19년 전 조회 1,980
19년 전 조회 3,121
19년 전 조회 1,863
19년 전 조회 2,331
19년 전 조회 2,402
19년 전 조회 3,981
19년 전 조회 3,166
19년 전 조회 3,091
19년 전 조회 2,535
19년 전 조회 1,995
19년 전 조회 1,637
19년 전 조회 2,406
19년 전 조회 2,327
19년 전 조회 1,816
19년 전 조회 1,812
19년 전 조회 2,601
19년 전 조회 2,576
19년 전 조회 1,875
19년 전 조회 2,106
19년 전 조회 3,293
19년 전 조회 1,947
19년 전 조회 2,491
19년 전 조회 2,566
19년 전 조회 2,657
19년 전 조회 2,933
19년 전 조회 2,560
19년 전 조회 2,974
19년 전 조회 2,758
19년 전 조회 3,511
19년 전 조회 1,866
19년 전 조회 2,730
19년 전 조회 2,368
19년 전 조회 2,017
19년 전 조회 2,425
19년 전 조회 1,869
19년 전 조회 5,437
19년 전 조회 2,254
19년 전 조회 4,239
19년 전 조회 2,295
19년 전 조회 1,845
19년 전 조회 2,587
19년 전 조회 2,327
19년 전 조회 2,525
19년 전 조회 2,162
19년 전 조회 3,910
19년 전 조회 3,415
19년 전 조회 2,197
19년 전 조회 2,104
19년 전 조회 1,971
19년 전 조회 1,989
19년 전 조회 4,367
19년 전 조회 3,348
19년 전 조회 2,773
19년 전 조회 3,346
19년 전 조회 2,997
19년 전 조회 2,836
19년 전 조회 2,339
19년 전 조회 2,158
19년 전 조회 2,484
19년 전 조회 3,093
19년 전 조회 2,119
19년 전 조회 3,114
19년 전 조회 3,246
19년 전 조회 2,916
19년 전 조회 1,937
19년 전 조회 1,699
19년 전 조회 2,315
19년 전 조회 2,251
19년 전 조회 1,622
19년 전 조회 1,656
19년 전 조회 1,559
19년 전 조회 2,066
19년 전 조회 1,613
19년 전 조회 2,178
19년 전 조회 1,908
19년 전 조회 1,798
19년 전 조회 1,645
19년 전 조회 1,838
19년 전 조회 1,885
19년 전 조회 1,942
19년 전 조회 2,687
19년 전 조회 5,315
19년 전 조회 1,718
19년 전 조회 1,565
19년 전 조회 1,432
19년 전 조회 1,589
19년 전 조회 1,522
19년 전 조회 1,442
19년 전 조회 1,448
19년 전 조회 1,371
19년 전 조회 1,440
🐛 버그신고