영카트 주문 중 선택한 것 엑셀 다운 소스 채택완료
주문 내역에서 버튼은
<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(", ", $_POST['chk']);
$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 od_id = '$od_id' ");
while($row = sql_fetch_array($que)) {
?>
<tr>
<td><?=$row['od_id']?></td>
</tr>
<?
}
?>
</table>
이것인데요 작동은 하는데 다수를 체크해도 하나밖에 나오지 않고 심지어 그 주문번호도 현재 없는 주문번호가 뜨네요 ㅠㅠ
소스 어디가 잘못된건가요?
답변 1개
체크된 od_id로 $where 라는 것을 실컷 만들어 놓고 막상 추출해 올때는
where od_id = '$od_id' <-- 이렇게 쿼리를 하고 있으니 나올리가 없습니다
$where 만드는 방법도 틀렸습니다
if($_POST['chk']) {
for ($i=0; $i<count($_POST['chk']); $i++) {
$k = $_POST['chk'][$i];
$od_id[] = $_POST['od_id'][$k]; <---수정
$od = implode(", ", $_POST['chk']); <--- 삭제
$where = "WHERE od_id IN($od)"; <--- 삭제
}
$od = implode(", ", $od_id);
$where = "WHERE od_id IN($od)";
}
------------------------------------------
$que = sql_query("SELECT * FROM {$g5['g5_shop_order_table']} where od_id = '$od_id' ");
--->
$que = sql_query("SELECT * FROM {$g5['g5_shop_order_table']} $where order by od_id");
답변에 대한 댓글 6개
<?
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>
로 수정했습니다
$od = implode(", ", $odid); <---수정
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인