주문 내역에서 버튼은
<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개 / 댓글 11개
/adm/board_list_update.php
여기를 보셔도 됩니다.
비슷한 예제입니다. 다만 여기는 for문장의 loop문입니다. 별반 차이 없습니다.~
답변에 대한 댓글 4개
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)) {
if ($_POST['act_button'] == "선택엑셀") {
?>
<tr>
<td style='mso-number-format:\@;'><?=$row['od_id']?></td>
</tr>
<?
}}
?>
</table>
그러시면 while문장과 if조건 문을 조금만 공부하시면 쉽게 해결할수있을리라 생각됩니다. 조금만 노력해서 한번 도전 해보시기는게 현실적으로 맞을듯싶습니다.~
답변에 대한 댓글 4개
보면 윗단에서 chk값이 넘어오면 od_id를 배열처리하구 합친거 같은데
아랫단에는 order_table에서 od_id를 가져온 거 같거든요?
제가 알기로 while은 반복해주는거로 알고 있는데 row줄로 od_id를 반복해준다는데
위에서 가져온거랑 연관이 있는건지도 모르겠고 if를 쓴다고 하더라도 어떻게 써야 할지 모르겠어요
이건 짧게 공부해서 되는게 아닌거 같은데요 ㅠㅠ
while문장에서 선택된부분에 대해서 if로 조건문 으로 해서 처리해주면될꺼 같습니다~
답변에 대한 댓글 3개
답변을 작성하려면 로그인이 필요합니다.