코멘트는 제외하고 불러오려고 하는데요.
랜덤으로 게시물을 불러오는형태인데요.
현재는 코멘트까지 가져오네요.
코멘트는 제외하고 원글만 가져올려고 한느데 어떻게 수정을 해야 할런지??
[code]
<?
$query = "SELECT count(wr_id) FROM g4_write_$bo_table";
$result = sql_query($query);
$row=mysql_fetch_array($result);
$num = rand(0,$row[0]-2);
$query = "SELECT * FROM g4_write_$bo_table limit $num, 2";
$result = sql_query($query);
for ($i=0; $row=mysql_fetch_array($result); $i++) {
$wr_subject = $row[wr_subject];
$rand_wr_id = $row[wr_id];
$wr_subject = get_text(cut_str($row[wr_subject], 22,""));
$query2 = "SELECT * FROM g4_board_file WHERE bo_table = '$bo_table' and wr_id = '$rand_wr_id' and bf_no = '1' ";
$result2 = sql_query($query2);
$row2 = mysql_fetch_array($result2);
$query3 = "SELECT * FROM g4_board_file WHERE bo_table = '$bo_table' and wr_id = '$rand_wr_id' and bf_no = '0' ";
$result3 = sql_query($query3);
$row3 = mysql_fetch_array($result3);
if ($row2) $img = "<img src='$g4[path]/data/file/$bo_table/$row2[bf_file]' width='80' height='70' border='0'>";
else $img = "<img src='$board_skin_path/img/no_img.gif' border='0'>";
?>
[/code]
현재는 코멘트까지 가져오네요.
코멘트는 제외하고 원글만 가져올려고 한느데 어떻게 수정을 해야 할런지??
[code]
<?
$query = "SELECT count(wr_id) FROM g4_write_$bo_table";
$result = sql_query($query);
$row=mysql_fetch_array($result);
$num = rand(0,$row[0]-2);
$query = "SELECT * FROM g4_write_$bo_table limit $num, 2";
$result = sql_query($query);
for ($i=0; $row=mysql_fetch_array($result); $i++) {
$wr_subject = $row[wr_subject];
$rand_wr_id = $row[wr_id];
$wr_subject = get_text(cut_str($row[wr_subject], 22,""));
$query2 = "SELECT * FROM g4_board_file WHERE bo_table = '$bo_table' and wr_id = '$rand_wr_id' and bf_no = '1' ";
$result2 = sql_query($query2);
$row2 = mysql_fetch_array($result2);
$query3 = "SELECT * FROM g4_board_file WHERE bo_table = '$bo_table' and wr_id = '$rand_wr_id' and bf_no = '0' ";
$result3 = sql_query($query3);
$row3 = mysql_fetch_array($result3);
if ($row2) $img = "<img src='$g4[path]/data/file/$bo_table/$row2[bf_file]' width='80' height='70' border='0'>";
else $img = "<img src='$board_skin_path/img/no_img.gif' border='0'>";
?>
[/code]
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 3개
원글의 경우
wr_id = wr_parent
코멘트의 경우
wr_parent = 원글의 wr_id 값입니다..
질의문에 wr_is_comment='0' 이걸 추가해보세요..
$query = "SELECT count(wr_id) FROM g4_write_$bo_table where wr_is_comment = '0' ";
$result = sql_query($query);
$row=mysql_fetch_array($result);
$num = rand(0,$row[0]-2);
$query = "SELECT * FROM g4_write_$bo_table where wr_is_comment = '0' limit $num, 2";