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

· 19년 전 · 2597
<?

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,452
19년 전 조회 2,212
19년 전 조회 3,235
19년 전 조회 3,296
19년 전 조회 3,035
19년 전 조회 4,869
19년 전 조회 2,697
19년 전 조회 3,311
19년 전 조회 3,142
19년 전 조회 1,992
19년 전 조회 3,129
19년 전 조회 1,873
19년 전 조회 2,339
19년 전 조회 2,414
19년 전 조회 3,989
19년 전 조회 3,178
19년 전 조회 3,107
19년 전 조회 2,543
19년 전 조회 2,005
19년 전 조회 1,648
19년 전 조회 2,419
19년 전 조회 2,337
19년 전 조회 1,827
19년 전 조회 1,823
19년 전 조회 2,613
19년 전 조회 2,583
19년 전 조회 1,886
19년 전 조회 2,118
19년 전 조회 3,303
19년 전 조회 1,957
19년 전 조회 2,498
19년 전 조회 2,574
19년 전 조회 2,668
19년 전 조회 2,945
19년 전 조회 2,570
19년 전 조회 2,982
19년 전 조회 2,768
19년 전 조회 3,521
19년 전 조회 1,878
19년 전 조회 2,738
19년 전 조회 2,376
19년 전 조회 2,028
19년 전 조회 2,431
19년 전 조회 1,883
19년 전 조회 5,447
19년 전 조회 2,268
19년 전 조회 4,250
19년 전 조회 2,305
19년 전 조회 1,855
19년 전 조회 2,598
19년 전 조회 2,339
19년 전 조회 2,534
19년 전 조회 2,177
19년 전 조회 3,920
19년 전 조회 3,422
19년 전 조회 2,205
19년 전 조회 2,114
19년 전 조회 1,984
19년 전 조회 2,001
19년 전 조회 4,384
19년 전 조회 3,358
19년 전 조회 2,780
19년 전 조회 3,361
19년 전 조회 3,006
19년 전 조회 2,846
19년 전 조회 2,347
19년 전 조회 2,169
19년 전 조회 2,498
19년 전 조회 3,105
19년 전 조회 2,131
19년 전 조회 3,123
19년 전 조회 3,255
19년 전 조회 2,926
19년 전 조회 1,947
19년 전 조회 1,709
19년 전 조회 2,326
19년 전 조회 2,260
19년 전 조회 1,632
19년 전 조회 1,665
19년 전 조회 1,567
19년 전 조회 2,080
19년 전 조회 1,631
19년 전 조회 2,187
19년 전 조회 1,919
19년 전 조회 1,813
19년 전 조회 1,656
19년 전 조회 1,845
19년 전 조회 1,897
19년 전 조회 1,948
19년 전 조회 2,699
19년 전 조회 5,322
19년 전 조회 1,728
19년 전 조회 1,577
19년 전 조회 1,441
19년 전 조회 1,599
19년 전 조회 1,533
19년 전 조회 1,452
19년 전 조회 1,462
19년 전 조회 1,385
19년 전 조회 1,448