티스토리 뷰
철판이 입고되면 그 철판의 단가를 월별로 비교하는 루틴을 제작중인데,
연구과제가 몇가지 있다.
<div class="container">
<div class="row mt-3 mb-1 p-1 m-2">
<table class="table table-hover table-border">
<thead class=" table-secondary">
<tr>
<th class="text-center">아이템</th>
<th class="text-center">월</th>
<th class="text-center">Kg당 단가 (원)</th>
</tr>
</thead>
<tbody>
<?php
try {
$current_month = date('Y-m');
$start_month = date('Y-m', strtotime('-23 months'));
for ($i = 23; $i >= 0; $i--) {
$target_month = date('Y-m-01', strtotime("$start_month +$i months"));
$next_month = date('Y-m-01', strtotime("$target_month +1 month"));
$sqlsearch = "SELECT item, spec, steelnum, suppliercost FROM mirae8440.cost WHERE outdate >= :target_month AND outdate < :next_month";
$stmt = $pdo->prepare($sqlsearch);
$stmt->bindParam(':target_month', $target_month);
$stmt->bindParam(':next_month', $next_month);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$item = $row['item'];
$spec = $row['spec'];
$steelnum = $row['steelnum'];
$suppliercost = $row['suppliercost'];
$temp_arr = explode('*', $spec);
$saved_weight = ($temp_arr[0] * $temp_arr[1] * $temp_arr[2] * 7.93 * (int)$steelnum) / 1000000;
$saved_weight = sprintf('%0.1f', $saved_weight);
$number = (int)str_replace(',', '', $suppliercost);
$unit_weight = $number > 0 ? number_format(floor($number / $saved_weight)) : 0;
echo "<tr>";
echo "<td class='text-center'>" . htmlspecialchars($item) . "</td>";
echo "<td class='text-center'>" . htmlspecialchars(substr($target_month, 0, 7)) . "</td>";
echo "<td class='text-center text-success'>" . htmlspecialchars($unit_weight) . "</td>";
echo "</tr>";
}
}
} catch (PDOException $Exception) {
error_log("오류: " . $Exception->getMessage());
}
?>
</tbody>
</table>
</div>
</div>
위의 코드를 활용해서 더 의미있는 자료를 만들어 내야 겠다~
'IT tech Coding > php' 카테고리의 다른 글
좌충우돌 코딩, 재고 자주 불러오는 부분 간소화 하기 (0) | 2024.02.21 |
---|---|
양식 다시 제출 확인이 웹페이지 나를 미치게 한다. (0) | 2023.11.20 |
`echo(json_encode($data, JSON_UNESCAPED_UNICODE));`와 `echo json_encode($data);`의 차이점 (0) | 2023.08.27 |
[php] 검색을 단순화해서 만들 수 있는 코드? 가능할까? (0) | 2023.08.21 |
특정문자열이 속한 span id에 색상 넣기 (0) | 2023.07.18 |
- Total
- Today
- Yesterday
- General error: 2031
- 뫄프로그래밍
- 도면자동생성
- isset을 적용해야 하는 이유
- 코딩효율성
- 엑셀입력보호
- 캐드자동작도
- #프로그램설치
- Bootstrap 5
- #파이썬패키징
- coalesce는 한국어로 "코얼레스크" 또는 "코얼리스"
- sql문장 날짜계산
- ajax오류메시지
- 엑셀보호
- 구글드라이브API
- json파일편하게보는법
- json파일형태보기
- 오토핫키가이드
- 스크립트작성기초
- 효율적코딩방법
- #InstallForge
- 파이썬코드줄바꿈방법
- 테크에능한여성
- 코딩튜토리얼
- 엑셀셀보호
- 오블완
- 1. #웹개발 2. #로트번호 3. #성적서보기 4. #ajax 5. #jquery 6. #php 7. #프론트엔드 8. #백엔드 9. #부트스트랩 10. #웹기능구현
- 티스토리챌린지
- chatGPT3.5파이썬버전
- 프로그래머생활
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |