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

· 19년 전 · 2587
<?

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,443
19년 전 조회 2,202
19년 전 조회 3,228
19년 전 조회 3,288
19년 전 조회 3,024
19년 전 조회 4,858
19년 전 조회 2,687
19년 전 조회 3,301
19년 전 조회 3,132
19년 전 조회 1,981
19년 전 조회 3,122
19년 전 조회 1,863
19년 전 조회 2,331
19년 전 조회 2,402
19년 전 조회 3,983
19년 전 조회 3,167
19년 전 조회 3,093
19년 전 조회 2,536
19년 전 조회 1,996
19년 전 조회 1,639
19년 전 조회 2,408
19년 전 조회 2,327
19년 전 조회 1,816
19년 전 조회 1,813
19년 전 조회 2,602
19년 전 조회 2,577
19년 전 조회 1,876
19년 전 조회 2,107
19년 전 조회 3,293
19년 전 조회 1,948
19년 전 조회 2,491
19년 전 조회 2,566
19년 전 조회 2,660
19년 전 조회 2,934
19년 전 조회 2,560
19년 전 조회 2,975
19년 전 조회 2,758
19년 전 조회 3,512
19년 전 조회 1,869
19년 전 조회 2,731
19년 전 조회 2,368
19년 전 조회 2,018
19년 전 조회 2,425
19년 전 조회 1,870
19년 전 조회 5,438
19년 전 조회 2,258
19년 전 조회 4,240
19년 전 조회 2,296
19년 전 조회 1,845
19년 전 조회 2,588
19년 전 조회 2,330
19년 전 조회 2,527
19년 전 조회 2,165
19년 전 조회 3,910
19년 전 조회 3,415
19년 전 조회 2,198
19년 전 조회 2,105
19년 전 조회 1,972
19년 전 조회 1,990
19년 전 조회 4,370
19년 전 조회 3,348
19년 전 조회 2,773
19년 전 조회 3,347
19년 전 조회 2,999
19년 전 조회 2,839
19년 전 조회 2,340
19년 전 조회 2,159
19년 전 조회 2,484
19년 전 조회 3,095
19년 전 조회 2,119
19년 전 조회 3,114
19년 전 조회 3,247
19년 전 조회 2,916
19년 전 조회 1,937
19년 전 조회 1,700
19년 전 조회 2,316
19년 전 조회 2,252
19년 전 조회 1,623
19년 전 조회 1,659
19년 전 조회 1,560
19년 전 조회 2,070
19년 전 조회 1,616
19년 전 조회 2,178
19년 전 조회 1,911
19년 전 조회 1,801
19년 전 조회 1,645
19년 전 조회 1,839
19년 전 조회 1,885
19년 전 조회 1,942
19년 전 조회 2,688
19년 전 조회 5,315
19년 전 조회 1,719
19년 전 조회 1,566
19년 전 조회 1,432
19년 전 조회 1,589
19년 전 조회 1,523
19년 전 조회 1,443
19년 전 조회 1,450
19년 전 조회 1,373
19년 전 조회 1,440
🐛 버그신고