$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활용안하셔도 됩니다.
제목 | 상태 | 답변수 | 글쓴이 | 날짜 |
---|---|---|---|---|
7 |
시크린가든 |
22/03/01 |
||
3 |
328늑대 |
22/02/13 |
||
4 |
연이84 |
22/02/09 |
||
8 |
달리는남자 |
22/02/02 |
||
3 |
눈부신그대 |
22/01/23 |
||
9 |
소망이넘침 |
21/12/20 |
||
14 |
안창해 |
21/11/06 |
||
9 |
여제n궁 |
21/11/03 |
||
2 |
호바기 |
21/10/02 |
||
5 |
푸마매니아 |
21/09/18 |
||
11 |
해보자1976 |
21/09/17 |
||
7 |
하얀민족 |
21/09/07 |
||
1 |
편리한집 |
21/09/07 |
||
1 |
매일행복하게 |
21/09/04 |
||
8 |
닉넴생각중 |
21/08/23 |
||
1 |
조선의거상 |
21/08/08 |
||
3 |
서예지 |
21/07/11 |
||
6 |
정권 |
21/05/29 |
||
1 |
tndi6 |
21/05/28 |
||
2 |
그사람여자 |
21/05/26 |