게시판에서 검색결과를 엑셀 출력 할려고 합니다. 정보
게시판에서 검색결과를 엑셀 출력 할려고 합니다.
본문
안녕하세요
문의 좀 드립니다.
현재는 게시판 전체 자료가 엑셀로 출력되는데요
검색을 하면 그 리스트를 엑셀로 출력을 할려고 합니다.
아래는 사용중인 소스 입니다.
출력 쿼리문을 어떻게 작성해야 할까요.
의문점이 검색폼에 wr_name 값의 단어를 치면 해당 검색 내용이 엑셀로 잘 넘어오는데
wr_2 / wr_3 으로 된 다중 셀렉트 값은 검색은 되는데 "출력할 자료가 없다고" 나오네요.
<?
include_once("./_common.php");
$sql = " select * from $g4[write_prefix]$bo_table";
if ($sfl){
$sql .= " where $sfl like '%$stx%' ";
}else{
$sql .= "";
}
if ($sst){
$sql .= " order by $sst $sod ";
}else{
$sql .=" order by wr_datetime asc ";
}
$result = sql_query($sql);
$cnt = @mysql_num_rows($result);
if (!$cnt)
alert("출력할 내역이 없습니다.");
header('Content-Type: application/vnd.ms-excel');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename="list' . date("ymd", time()) . '.xls"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('content-transfer-encoding: binary');
echo "<html><head>";
echo "<meta http-equiv='Content-Type' content='application/vnd.ms-excel;charset=utf-8'>";
echo "</head><body>";
echo "<table border=1 style='font-family:돋움; font-size:10pt;'><tr>";
echo "
<td style=font-weight:bold;>번호</td>
<td style=font-weight:bold;>신청일</td>
<td style=font-weight:bold;>참가부문</td>
<td style=font-weight:bold;>작품제목</td>
<td style=font-weight:bold;>이름</td>
<td style=font-weight:bold;>학교학년(학원명)</td>
<td style=font-weight:bold;>핸드폰</td>
<td style=font-weight:bold;>주소</td>
<td style=font-weight:bold;>연락처1</td>
<td style=font-weight:bold;>연락처2</td>
</tr>\n";
$i = 0;
while($data=mysql_fetch_array($result)) {
$i++;
$tmp = explode("|",$data[wr_1]);
// 날짜에 월,일 구분 "-" 넣기
$tmp_date = substr($tmp[0],0,4).-substr($tmp[0],4,2).-substr($tmp[0],6,2);
echo "<tr>\n";
echo "<tr height=25> ";
echo "<td>$i</td>";
echo "<td>$data[wr_datetime]</td>";
echo "<td>$data[wr_2]-$data[wr_3]</td>";
echo "<td>$data[wr_subject]</td>";
echo "<td>$data[wr_name]</td>";
echo "<td>$tmp[9]</td>";
echo "<td>$tmp[1]$data[wr_10]-$tmp[2]-$tmp[3]</td>";
echo "<td>($tmp[5]-$tmp[6]) $tmp[7] $tmp[8]</td>";
echo "<td>$tmp[4]</td>";
echo "<td>$tmp[10]</td>";
echo "</tr>";
}
echo "</table>";
echo "</body></html>";
if ($i == 0)
alert("자료가 없습니다.");
exit;
?>
문의 좀 드립니다.
현재는 게시판 전체 자료가 엑셀로 출력되는데요
검색을 하면 그 리스트를 엑셀로 출력을 할려고 합니다.
아래는 사용중인 소스 입니다.
출력 쿼리문을 어떻게 작성해야 할까요.
의문점이 검색폼에 wr_name 값의 단어를 치면 해당 검색 내용이 엑셀로 잘 넘어오는데
wr_2 / wr_3 으로 된 다중 셀렉트 값은 검색은 되는데 "출력할 자료가 없다고" 나오네요.
<?
include_once("./_common.php");
$sql = " select * from $g4[write_prefix]$bo_table";
if ($sfl){
$sql .= " where $sfl like '%$stx%' ";
}else{
$sql .= "";
}
if ($sst){
$sql .= " order by $sst $sod ";
}else{
$sql .=" order by wr_datetime asc ";
}
$result = sql_query($sql);
$cnt = @mysql_num_rows($result);
if (!$cnt)
alert("출력할 내역이 없습니다.");
header('Content-Type: application/vnd.ms-excel');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename="list' . date("ymd", time()) . '.xls"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('content-transfer-encoding: binary');
echo "<html><head>";
echo "<meta http-equiv='Content-Type' content='application/vnd.ms-excel;charset=utf-8'>";
echo "</head><body>";
echo "<table border=1 style='font-family:돋움; font-size:10pt;'><tr>";
echo "
<td style=font-weight:bold;>번호</td>
<td style=font-weight:bold;>신청일</td>
<td style=font-weight:bold;>참가부문</td>
<td style=font-weight:bold;>작품제목</td>
<td style=font-weight:bold;>이름</td>
<td style=font-weight:bold;>학교학년(학원명)</td>
<td style=font-weight:bold;>핸드폰</td>
<td style=font-weight:bold;>주소</td>
<td style=font-weight:bold;>연락처1</td>
<td style=font-weight:bold;>연락처2</td>
</tr>\n";
$i = 0;
while($data=mysql_fetch_array($result)) {
$i++;
$tmp = explode("|",$data[wr_1]);
// 날짜에 월,일 구분 "-" 넣기
$tmp_date = substr($tmp[0],0,4).-substr($tmp[0],4,2).-substr($tmp[0],6,2);
echo "<tr>\n";
echo "<tr height=25> ";
echo "<td>$i</td>";
echo "<td>$data[wr_datetime]</td>";
echo "<td>$data[wr_2]-$data[wr_3]</td>";
echo "<td>$data[wr_subject]</td>";
echo "<td>$data[wr_name]</td>";
echo "<td>$tmp[9]</td>";
echo "<td>$tmp[1]$data[wr_10]-$tmp[2]-$tmp[3]</td>";
echo "<td>($tmp[5]-$tmp[6]) $tmp[7] $tmp[8]</td>";
echo "<td>$tmp[4]</td>";
echo "<td>$tmp[10]</td>";
echo "</tr>";
}
echo "</table>";
echo "</body></html>";
if ($i == 0)
alert("자료가 없습니다.");
exit;
?>
댓글 전체