게시판 목록들 중 최신 게시글 가져와서 메인 화면에 보여주기
본문
안녕하세요 초보자입니다.
게시판 목록들 중에서 최신 게시글을 가져와서 메인 화면에 보여주기를 하는 소스에서요
최신 글 20개만 보여지게 하고 싶은데
어찌 처리를 해야 할지 몰라서요..
고수님들의 조언을 부탁드립니다.
[현재 사용중인 소스입니다.]
<?
include_once("./_common.php");
$sql = " select * from g4_write_goods where wr_is_comment = 0 order by wr_id desc limit 30";
$result = sql_query($sql, false);
?>
<html>
<head>
<style type="text/css">
table{width:100%; border-spacing:0;border-collapse:collapse;}
td{ text-align:center; font-size:12px;}
a:link, a:visited, a:active { text-decoration:none; color:#466C8A; }
a:hover { text-decoration:none; color:#466C8A;}
</style>
<script>
// banner_roll("div태그 id", 배너1개높이, 딜레이, 1칸이동속도, 0);
function banner_roll(div_id, banner_height, banner_delay, banner_speed, this_height)
{
var div_tag = document.getElementById(div_id);
var a_tag, i;
this_height ++;
if(this_height < banner_height) {
div_tag.style.top = -this_height;
setTimeout("banner_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ");", banner_speed);
} else {
a_tag = div_tag.getElementsByTagName("A");
div_tag.appendChild(a_tag[0]);
div_tag.style.top = 0;
setTimeout("banner_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", 0);", banner_delay);
}
return true;
}
</script>
</head>
<body topmargin="0" leftmargin="0" bgcolor="#FFFFFF" >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="720" height="190" align="center">
<div style="width:720px; height:190px; overflow:hidden;padding:4px;">
<div style="position:relative;" id="banner_1">
<?
$i=0;
$arr_img=array("","","","","");
while ($row = sql_fetch_array($result))
{
$sql2 = " select * from g4_board_file where bo_table='goods' and wr_id=$row[wr_id] ";
$result2 = sql_query($sql2, false);
$row2=sql_fetch_array($result2);
$img="<a href=".$g4['path']."/bbs/board.php?bo_table=goods&wr_id=".$row[wr_id]." target=_parent>";
$img.="<img src=".$g4['path']."/data/file/goods/".$row2[bf_file]." width=130 height=150 border=0 /></a>";
$tblstr="<table cellspacing=0 cellpadding=0 border=0><tr><td align=center height=150 style='border:1px solid #0066A7;'>".$img."</td></tr><tr><td align=center height=32 style='border:1px solid #0066A7;'><B>".$row[wr_subject]."</B></td></tr></table>";
$arr_img[$i] = $tblstr;
$i++;
if ($i==5)
{
$i=0;
} else {
continue;
}
?>
<a href="#" style="display:block; height:190px;">
<table width="720" height="190" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="140"><?=$arr_img[0]?></td>
<td width="5"></td>
<td width="140"><?=$arr_img[1]?></td>
<td width="5"></td>
<td width="140"><?=$arr_img[2]?></td>
<td width="5"></td>
<td width="140"><?=$arr_img[3]?></td>
<td width="5"></td>
<td width="140"><?=$arr_img[4]?></td>
</tr>
<tr>
<td colspan="9" height="5"></td>
</tr>
</table>
</a>
<?
}
?>
</div>
</div>
</td>
<tr>
</table>
<script>
banner_roll("banner_1", 190, 2000, 10, 0);
</script>
</body>
</html>