채택완료

도대체 모르겠습니다

2018-05-02 (수) 18:55:25 2,071

주문 내역에서 체크된 것만 엑셀로 받는걸 만들고 있습니다

주문 내역에서 버튼은

<span onclick="Excel()">[excel]</span>

이것이고

스크립트는

function Excel() {

var fm = document.forderlist;
 fm.target = "hiddenframe";
 fm.action = "orderlist_ex2.php";
 fm.method = "post";
 fm.submit();
}

이것입니다.

orderlist_ex2.php 의 내용은

<?
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=file.xls");
header("Content-Description: PHP4 Generated Data");

include "_common.php";

if($_POST['chk']) {
for ($i=0; $i<count($_POST['chk']); $i++) {

$k    = $_POST['chk'][$i];
$od_id[] = $_POST['od_id'][$k];

}
$od = implode(", ", $od_id);
$where = "WHERE od_id IN($od)";
}
?>
<table border="1">
<tr>
<th>od_id</th>
</tr>
<?
$que = sql_query("SELECT * FROM {$g5['g5_shop_order_table']} $where order by od_id");
while($row = sql_fetch_array($que)) {
?>
<tr>
<td style='mso-number-format:\@;'><?=$row['od_id']?></td>
</tr>
<?
}
?>
</table>

입니다. 정상적으로 엑셀은 다운 되는데 선택된 것이 아닌 현재 페이지 전체의 주문번호가 나오네요.

어디가 잘 못 된 걸까요? ㅠㅠ

|

답변 3개 / 댓글 2개

채택된 답변
+20 포인트

아래에서도 여러번 설명드렸는데..아직도 이해를 못하신듯해서요..

/adm/board_list_update.php 관리자쪽 이쪽을 참고 해보세요~

답변에 대한 댓글 1개

모르겠네요 ㅠㅠ
위에서 체크배열 해주고 체크 합쳐주고 밑에서 합쳐준 $where로 셀렉트 해주고 그걸 $row로 반복시켜주는건데 뭐가 잘못됐는지 뭘 추가해야 하는지 전혀 모르겠어요

나름 설명을 잘 드리고 예제도 드렸는데요...

죄송하지만 그냥 의뢰하시는게 더 효과적일듯하네요..

답변에 대한 댓글 1개

해결했어요 감사합니다~!
2018-05-02 (수) 19:48:05

<?
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=file.xls");
header("Content-Description: PHP4 Generated Data");

include "_common.php";

?>
<table border="1">
    <tr>
        <th>od_id</th>
    </tr>
    <?
    if ($_POST['act_button'] == "선택엑셀") {

        for ($i=0; $i<count($_POST['chk']); $i++) {

        $k     = $_POST['chk'][$i];
        $od_id = $_POST['od_id'][$k];
        while($row = sql_fetch_array($od_id)) {
    ?>
    <tr>
        <td style='mso-number-format:\@;'><?=$row['od_id']?></td>
    </tr>
    <?
        }}}
    ?>
</table>


이렇게 해봤는데 이건 아예 안나오네요 ㅠㅠ

답변을 작성하려면 로그인이 필요합니다.