$conn = mysql_connect(localhost,11,123) or message(mysql_error()); //localhost默认主机地址,数据库名,密码
mysql_select_db(11, $conn ) or message(mysql_error()); //数据库名称
// Function Recent Comment
function recent_cmt($num=10, $textlen=30, $datetype="Y年m月d日 H分i秒") {
global $_zb_url, $connect, $t_board, $t_comment, $mb_id, $mb_conf, $t_category;
// get and set variable
$id = $mb_id; // get IDs
$cutTimeMode = $mb_conf[timemode]; // get time mode
$tc = 0; //Total Counts
// timeMode (1: in 24 hours; 2: today;)
if($cutTimeMode == 1){
$cut_time = time() - 3600 * 24; // 24hours
}else if($cutTimeMode == 2){
$cut_time = mktime(0,0,0,date("m"),date("d"),date("Y")); // today
}else{
$cut_time = 0; // normal
}
// get values from database
for( $i = 0; $i < sizeof($id); $i++){
// get subject data
$query = "select * from ".$t_board."_".$id[$i]." where reg_date > $cut_time order by no desc limit $num";
$result = mysql_query($query, $connect) or die(mysql_error());
while($data=mysql_fetch_array($result)){
// subject data
$cmt[$tc][no] = $data[no];
$cmt[$tc][name] = stripslashes($data[name]);
$cmt[$tc][parent] = $data[parent];
$cmt[$tc][date] = date($datetype, $data[reg_date]);
$cmt[$tc][reg_date] = $data[reg_date];
$cmt[$tc][memo] = cut_str(stripslashes($data[subject]), $textlen);
// get parent data
$p_data = mysql_fetch_array(mysql_query("select * from $t_comment"."_$id[$i] where no='$data[parent]'"));
$cmt[$tc][p_subject] = cut_str(stripslashes($p_data[subject]), 100);
$cmt[$tc][p_name] = stripslashes($p_data[name]);
$cmt[$tc][p_date] = date($datetype, $p_data[reg_date]);
$cmt[$tc][p_target] = $_zb_url."view.php?id=".$id[$i]."&no=".$data[no];
// ready for sorting
$tm[$tc] = $data[reg_date]."_$tc";
$map[$data[reg_date]."_$tc"] = $tc;
$tc++;
}
}
// sort by time
if($tc)
sort($tm);
// output
for($i = sizeof($tm)-1; $i >= sizeof($tm)-$num && $i >= 0; $i--){
$n = $map[$tm[$i]];
<font color=blue>print</font> "<font color=red><</font>tr>";
<font color=blue>print</font>" <font color=red><</font>td height=24 align=left>·[".$cmt[$n][name]."]";
<font color=blue>print</font> "<font color=red><</font>a href=".$cmt[$n][p_target].">";
<font color=blue>print</font> $cmt[$n][memo]."<font color=red><</font>/a><font color=red><</font>/td>";
<font color=blue>print</font>"<font color=red><</font>tr>";
}
게시물 수출용
<font color=red><</font>?
$mb_id = array("w1", "w2", "w3", "w4"); //w1,w2,w3,w4는 게시판 아이디.
$mb_conf[timemode] = 0;
recent_cmt(8,24);
?<font color=red>></font>
빠른답변 감사합니다.
윗부분의 소스를 폴드로 만들어 게시물 추출할 페이지 상단에 인쿨루드해서 사용하나요?
완전 초보라서 ...
사용방법좀 상세히 알려주시면 고맙겠습니다.
outlogin.php 마지막에 넣으서 할려니까 에러가 나서 마지막에 } 이걸 하나 더 부치니까 되네요.그리고 아래 부분에서
print "<tr>";
print" <td height=24 align=left>·[".$cmt[$n][name]."]";
print "<a href=".$cmt[$n][p_target].">";
print $cmt[$n][memo]."</a></td>";
print"<tr>";
이데로 사용하니까 홈페이지 테이블이 깨져서
print "<table>";
print "<tr>";
print" <td height=24 align=left>·[".$cmt[$n][name]."]";
print "<a href=".$cmt[$n][p_target].">";
print $cmt[$n][memo]."</a></td>";
print"</tr>";
print"</table>";
}
}
이렇게 고치니까 잘 나오네요.
혹시 수정한 부분이 틀렸으면 알려주세요.
아무튼 감사합니다.
아~그리고마지막 부분에 print"<tr>"; 이걸 print"</tr>"; 이렇게 고쳐주야 하네요~
제가 적어준 소스를 페이지 상단에 복사해주시고요(계정에 맞게 적어주셔야 합니다. 즉 디비 정보)
그리고 아래 게시물 수출용
<font color=red><</font>?
$mb_id = array("w1", "w2", "w3", "w4"); //w1,w2,w3,w4는 게시판 아이디.
$mb_conf[timemode] = 0;
recent_cmt(8,24);
?<font color=red>></font>소스를 원하는 곳에 카피해주시면 됩니다.
outlogin.php활용안하셔도 됩니다.
제목 | 상태 | 답변수 | 글쓴이 | 날짜 |
---|---|---|---|---|
2 |
젊은이 |
20/01/08 |
||
3 |
블리블리101 |
20/01/06 |
||
8 |
hua0909 |
20/01/01 |
||
2 |
인연과연분 |
19/12/19 |
||
0 |
rheheorlf |
19/12/14 |
||
1 |
와인맛립스틱 |
19/12/12 |
||
3 |
화룡해란강 |
19/12/09 |
||
2 |
yjcui |
19/12/07 |
||
1 |
무잽이데이 |
19/12/03 |
||
5 |
시집가야죠 |
19/12/03 |
||
2 |
Bijou |
19/11/24 |
||
2 |
너라서좋아 |
19/11/18 |
||
3 |
후회없는선택 |
19/10/28 |
||
4 |
쩡아쮸아V왑 |
19/10/27 |
||
2 |
주문89 |
19/10/09 |
||
3 |
KyungGook |
19/10/04 |
||
2 |
나나빠 |
19/09/11 |
||
31 |
19/09/10 |
|||
0 |
플라이펭귄 |
19/09/06 |
||
4 |
19/09/03 |