sms 전송내역을 가져오고 싶은데요 채택완료
알리고라는 곳에서 sms를 사용하고 있습니다.
발송은 잘 되는데요
발송내역을 보는 페이지가 아래와 같습니다.
http://sir.kr/data/editor/2411/3034902428_1732092353.9976.jpg" />
내용은 이런식으로 나옵니다.
{"result_code":1,"message":"success","list":[{"mid":"931412587","type":"LMS","sender":"0632887797","sms_count":"1","reserve_state":"","msg":"JB\ubb38\ud654\uacf5\uac04 \uc804\uc8fc-\ud504\ub85c\uadf8\ub7a8 \ucc38\uac00\ub97c \uc2e0\uccad\ud558\uc168\uc2b5\ub2c8\ub2e4. \ud589\uc0ac\uba85 : \uaca8\uc6b8 \ub9c8\uc220\uad50\uc2e4 \ub0a0\uc9dc : 2024-11-28 ~ 2024-12-19 \uc2dc\uac04 : 2:00 PM ~ 3:00 PM","fail_count":"0","reg_date":"2024-11-19 22:09:57","reserve":""},{"mid":"931193243","type":"LMS","sender":"0632887797","sms_count":"1","reserve_state":"","msg":"JB\ubb38\ud654\uacf5\uac04 \uc804\uc8fc................
여기에 발송내용,성공실패,발송일시등이 나오는것 같은데
이것을 페이지에 뿌리고 싶은데 어떻게 가져와야 할지를 모르겠습니다.
알려주시면 감사하겠습니다.
답변 2개
</p>
<p>$result = json_decode($ret, true); // 결과 배열</p>
<p>// 결과 출력을 위한 페이지 구성
$g5['title'] = 'SMS 발송내역';
?></p>
<p><div class="tbl_head01 tbl_wrap">
<table>
<caption>SMS 발송내역</caption>
<thead>
<tr>
<th scope="col">번호</th>
<th scope="col">발송유형</th>
<th scope="col">발신번호</th>
<th scope="col">메시지</th>
<th scope="col">발송건수</th>
<th scope="col">실패건수</th>
<th scope="col">발송일시</th>
<th scope="col">상태</th>
</tr>
</thead>
<tbody>
<?php
if ($result['result_code'] == 1 && !empty($result['list'])) {
foreach($result['list'] as $i => $row) {
$num = $result['count'] - $i;
?>
<tr>
<td class="td_num"><?php echo $num ?></td>
<td class="td_type"><?php echo $row['type'] ?></td>
<td class="td_tel"><?php echo $row['sender'] ?></td>
<td class="td_msg"><?php echo $row['msg'] ?></td>
<td class="td_num"><?php echo $row['sms_count'] ?></td>
<td class="td_num"><?php echo $row['fail_count'] ?></td>
<td class="td_datetime"><?php echo $row['reg_date'] ?></td>
<td class="td_status">
<?php
if ($row['fail_count'] > 0) {
echo '<span class="status_fail">실패</span>';
} else {
echo '<span class="status_success">성공</span>';
}
?>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="8" class="empty_table">발송내역이 없습니다.</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div></p>
<p><style>
.td_type { width: 80px; }
.td_tel { width: 120px; }
.td_msg { text-align: left; padding-left: 10px !important; }
.td_num { width: 70px; text-align: center; }
.td_datetime { width: 140px; }
.td_status { width: 80px; }
.status_success { color: #3c763d; }
.status_fail { color: #a94442; }
</style></p>
<p>
답변에 대한 댓글 2개
if ($result['result_code'] == 1 && !empty($result['list'])) {
foreach($result['list'] as $i => $row) {
$num = $result['count'] - $i;
?>
->
<?php
if ($result['result_code'] == 1 && !empty($result['list'])) {
$total_count = count($result['list']); // 목록 개수를 직접 카운트
foreach($result['list'] as $i => $row) {
$num = $total_count - $i; // 전체 개수에서 현재 인덱스를 뺌
?>
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
한가지만 여쭙겠습니다.
$result['count'] 에서 전체 데이터의 갯수를 뽑아오는것 같은데
다른 정보들은 다 정상적으로 들어옵니다만. $result['count']가 0이 되어서
번호가0, -1, -2...이렇게 갑니다. 이것을 어떻게 정상적으로 받아올수 있을까요?
답변 부탁드립니다.
감사합니다.