그누보드5 첨부파일 갯수 카운트하는 것좀 부탁드리겠습니다 ㅎ 채택완료
안녕하세요
아까에 이어서 또 질문올리는데요~
하단의 소스로 wr_id 가 1인 게시판의 첨부된파일 5개를 이미지로 뽑아오는데 성공은했는데
5를 입력하는데시에 해당게시글에 첨부된 파일갯수를 카운트해서 자동으로 5가 될수 있게 할수 없을까요~?
$g4[board_file_table] = "g5_board_file";
$bo_table = "gallery2";
$myDomain = $_SERVER['HTTP_HOST'];
/*
$sql = " select bf_file from $g4[board_file_table] where bo_table='$bo_table' and wr_id = '1' order by bf_no";
$result = sql_query($sql);
$row = mysql_fetch_array($result);
echo count($row);
*/
$imgCount = 5;// 첨부 이미지갯수
for($i=0;$i<$imgCount;$i++){
$sql = " select bf_file from $g4[board_file_table] where bo_table='$bo_table' and wr_id = '1' order by bf_no limit $i, 1";
$result = sql_query($sql);
$row = mysql_fetch_array($result);
$filename = $row[bf_file];
$gbimageurl = "http://{$myDomain}/data/file">http://{$myDomain}/data/file";
$gbimage = "$gbimageurl/$bo_table/$filename";
echo "";
}
?>
답변 1개
그누보드 4를 안쓰고 있어서 테이블이랑 필드명이 생각안나네요..
</p><p><span style="font-family: gulim, helvetica; line-height: 23.5440006256104px; font-size: 10pt; background-color: rgb(255, 255, 255);">$imgCount = 5;// 첨부 이미지갯수</span></p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);">for($i=0;$i<$imgCount;$i++){</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $sql = " select bf_file from $g4[board_file_table] where bo_table='$bo_table' and wr_id = '1' order by bf_no limit $i, 1";</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $result = sql_query($sql);</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $row = mysql_fetch_array($result);</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $filename = $row[bf_file];</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $gbimageurl = "<a href="<a href="http://%7B%24mydomain%7D/data/file" target="_blank" rel="noopener noreferrer">http://%7B%24mydomain%7D/data/file</a>" target="_blank" style="color: rgb(0, 0, 0);"><a href="http://{$myDomain}/data/file" target="_blank" rel="noopener noreferrer">http://{$myDomain}/data/file</a></a>";</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $gbimage = "$gbimageurl/$bo_table/$filename";</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> echo "<img src=$gbimage ?>";</p><p><span style="font-family: gulim, helvetica; line-height: 23.5440006256104px; font-size: 10pt; background-color: rgb(255, 255, 255);">}</span> </p><p>
이 부분의 for문을 while 문으로 돌려주시면 됩니다.
</span></p><p><span style="font-size: 10pt; line-height: 1.5;"></span><span style="font-size: 10pt; line-height: 1.5;"></span><span style="font-family: gulim, helvetica; line-height: 23.5440006256104px; font-size: 10pt; background-color: rgb(255, 255, 255);">$sql = " select bf_file from $g4[board_file_table] where bo_table='$bo_table' and wr_id = '1' ";</span><span style="font-size: 10pt; line-height: 1.5;"></span></p><p>$rst = mysql_query($sql);</p><p>$rcd = mysql_num_rows($rst);</p><p>$tfd = mysql_num_fields($rst);</p><p><span style="font-size: 10pt; line-height: 1.5;">while ($row = mysql_fetch_array($rst)) { </span></p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $filename = $row[bf_file];</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $gbimageurl = "<a href="<a href="http://%7B%24mydomain%7D/data/file" target="_blank" rel="noopener noreferrer">http://%7B%24mydomain%7D/data/file</a>" target="_blank" style="color: rgb(0, 0, 0);"><a href="http://{$myDomain}/data/file" target="_blank" rel="noopener noreferrer">http://{$myDomain}/data/file</a></a>";</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> $gbimage = "$gbimageurl/$bo_table/$filename";</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; background-color: rgb(255, 255, 255);"> echo "<img src=$gbimage ?>";</p><p><span style="font-family: gulim, helvetica; line-height: 23.5440006256104px; font-size: 10pt; background-color: rgb(255, 255, 255);">}</span> </p><p><span style="font-size: 10pt; line-height: 1.5;">
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인