메인에 게시물수를 넣을 수 있나요..?
본문
오늘의 게시물 수: 20개
전체 게시물 수 :390개
요런식으로요..
답변 2
이렇게 해보세요
$sql = "select count(*) as cnt from g5_write_테이블 where LEFT(wr_datetime,10) = '".G5_TIME_YMD."'";
$res = sql_fetch($sql);
echo "오늘 게시물 수 : ".$res['cnt'];
echo "<br>";
$sql = "select count(*) as cnt from g5_write_테이블 where1";
$res = sql_fetch($sql);
echo "전체 게시물 수 : ".$res['cnt'];
질문의 답변으로만 하자면
네 가능합니다.
방법을 물어보시는거면
<?php
include_once ("../common.php");
$sql = "select bo_table from g5_board "; //를 이용해서
//테이블명을 추출하고 해당 쿼리를 while 문등의 루프를 이용해
$result = sql_query($sql);
$today = 0;
$total = 0;
while($row = sql_fetch_array($result)) {
$sql2 = "select count(*) cnt from g5_write_".$row['bo_table'];
$row2 = sql_fetch($sql2);
if ($row2['cnt'])
$total += $row2['cnt'];
$sql2 .= " where date(wr_datetime) = curdate() ";
$row3 = sql_fetch($sql2);
if ($row3['cnt'])
$today += $row3['cnt'];
}
echo "오늘 : ".$today."개<br/>";
echo "전체 : ".$total."개<br/>";
와 같이 적용하면
$today 와 $total 변수를 이용하시면 될듯 싶은데요
먼저올렸다가 오타가 있어서 수정했어요
답변을 작성하시기 전에 로그인 해주세요.