테스트 사이트 - 개발 중인 베타 버전입니다

영카트 주문 중 선택한 것 엑셀 다운 소스 채택완료

블랑숑 7년 전 조회 2,084

주문 내역에서 버튼은

 

<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개

채택된 답변
+20 포인트
7년 전

체크된 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개

블랑숑
7년 전
앗 무지랭이라 송구합니다 ㅜㅜ 내일 당장 적용시켜볼게요 너무너무 감사합니나
블랑숑
7년 전
균이님 너무 죄송한데 지금 해보니깐요 선택한 것이 아니라 현재 페이지 전체의 주문번호가 나오구요 끝번호가 0이 되어 나오네요. (예를 들면 20180425-10435563 이면 2018042510435560) 어떻게 해야할까요? ㅠㅠ
블랑숑
7년 전
끝자리 0나오는건 검색해서 해결했는데요 선택한게 안나오고 전체가 나오는건 어찌해야 할까요?
블랑숑
7년 전
현재 소스는

<?
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>

로 수정했습니다
균이
7년 전
$odid[] = $_POST['od_id'][$k]; <---수정

$od = implode(", ", $odid); <---수정
블랑숑
7년 전
아 그렇게 하니 array 안해도 되네요 너무 감사합니다 행복한 하루되세요 좋은 일만 생기세요~!

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

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

로그인