--- 20220126/Address.php
+++ 20220126/Address.php
... | ... | @@ -12,6 +12,17 @@ |
12 | 12 |
$this->db = $db->getDB(); |
13 | 13 |
} |
14 | 14 |
|
15 |
+ public function getListWhere($no) { |
|
16 |
+ try { |
|
17 |
+ $stmt = $this->db->prepare("select * from address where no = ?"); |
|
18 |
+ $stmt->execute(array($no)); |
|
19 |
+ $result = $stmt->fetchAll(); |
|
20 |
+ return $result; |
|
21 |
+ }catch (PDOException $e) { |
|
22 |
+ return $e; |
|
23 |
+ } |
|
24 |
+ } |
|
25 |
+ |
|
15 | 26 |
public function getList() { |
16 | 27 |
try { |
17 | 28 |
$stmt = $this->db->prepare("select * from address"); |
--- 20220126/address_delete.php
+++ 20220126/address_delete.php
... | ... | @@ -1,16 +1,27 @@ |
1 |
+<script> |
|
2 |
+ let deleteConfirm = confirm("Are You Sure?"); |
|
3 |
+</script> |
|
1 | 4 |
<?php |
5 |
+ |
|
6 |
+ $deleteConfirm = "<script>document.write(deleteConfirm);</script>"; |
|
7 |
+ print($deleteConfirm); |
|
2 | 8 |
require_once("Address.php"); |
3 | 9 |
|
4 | 10 |
$no = $_GET['no']; |
5 | 11 |
|
6 | 12 |
$address = new Address(); |
7 | 13 |
|
8 |
- $result = $address->deleteTest($no); |
|
9 |
- if($result) { |
|
10 |
- echo "<script>alert('Delete Success!!!')</script>"; |
|
11 |
- echo "<script>document.location.href='address_view.php'</script>"; |
|
12 |
- }else { |
|
13 |
- echo "<script>alert('Delete Fail!!!')</script>"; |
|
14 |
- echo "<script>document.location.href='address_view.php'</script>"; |
|
15 |
- } |
|
16 | 14 |
|
15 |
+ |
|
16 |
+ if($deleteConfirm == TRUE){ |
|
17 |
+ $result = $address->deleteTest($no); |
|
18 |
+ if($result) { |
|
19 |
+ echo "<script>alert('Delete Success!!!')</script>"; |
|
20 |
+ echo "<script>document.location.href='address_view.php'</script>"; |
|
21 |
+ }else { |
|
22 |
+ echo "<script>alert('Delete Fail!!!')</script>"; |
|
23 |
+ echo "<script>document.location.href='address_view.php'</script>"; |
|
24 |
+ } |
|
25 |
+ }else{ |
|
26 |
+ |
|
27 |
+ } |
--- 20220126/address_update_front.php
+++ 20220126/address_update_front.php
... | ... | @@ -1,3 +1,8 @@ |
1 |
+<?php |
|
2 |
+ require_once("Address.php"); |
|
3 |
+ $address = new Address(); |
|
4 |
+ $list = $address->getListWhere($_GET['no']); |
|
5 |
+?> |
|
1 | 6 |
<!doctype html> |
2 | 7 |
<html lang="ko"> |
3 | 8 |
<head> |
... | ... | @@ -10,27 +15,27 @@ |
10 | 15 |
<body> |
11 | 16 |
<form action="address_update_back.php?no=<?php echo $_GET['no'] ?>" method="post"> |
12 | 17 |
<label for="name"> |
13 |
- 이름 : <input type="text" name="name" size="5"> |
|
18 |
+ 이름 : <input type="text" name="name" size="5" value="<?php echo $list[0][1]; ?>"> |
|
14 | 19 |
</label> |
15 | 20 |
<label for="age"> |
16 |
- 나이 : <input type="text" name="age" size="2"> |
|
21 |
+ 나이 : <input type="text" name="age" size="3" value="<?php echo $list[0][2]; ?>"> |
|
17 | 22 |
</label> |
18 | 23 |
<label for="tel"> |
19 |
- 연락처 : <input type="text" name="tel" size="8"> |
|
24 |
+ 연락처 : <input type="text" name="tel" size="10" value="<?php echo $list[0][3]; ?>"> |
|
20 | 25 |
</label><br> |
21 | 26 |
<label for="area"> |
22 | 27 |
거주지 : |
23 |
- <select name="area"> |
|
24 |
- <option value="광주">광주</option> |
|
25 |
- <option value="서울">서울</option> |
|
26 |
- <option value="대전">대전</option> |
|
27 |
- <option value="전주">전주</option> |
|
28 |
- <option value="부산">부산</option> |
|
29 |
- <option value="울산">울산</option> |
|
28 |
+ <select name="area" "<?php echo $list[0][4]; ?>"> |
|
29 |
+ <option value="광주" <?php if($list[0][4] == '광주') echo 'selected'; ?>>광주</option> |
|
30 |
+ <option value="서울" <?php if($list[0][4] == '서울') echo 'selected'; ?>>서울</option> |
|
31 |
+ <option value="대전" <?php if($list[0][4] == '대전') echo 'selected'; ?>>대전</option> |
|
32 |
+ <option value="전주" <?php if($list[0][4] == '전주') echo 'selected'; ?>>전주</option> |
|
33 |
+ <option value="부산" <?php if($list[0][4] == '부산') echo 'selected'; ?>>부산</option> |
|
34 |
+ <option value="울산" <?php if($list[0][4] == '울산') echo 'selected'; ?>>울산</option> |
|
30 | 35 |
</select> |
31 | 36 |
</label> |
32 | 37 |
<label for="birth"> |
33 |
- 생년월일 : <input type="date" name="birth"> |
|
38 |
+ 생년월일 : <input type="date" name="birth" value="<?php echo $list[0][5]; ?>"> |
|
34 | 39 |
</label> |
35 | 40 |
<br><button type="submit">수정</button> |
36 | 41 |
</form> |
--- 20220126/address_view.php
+++ 20220126/address_view.php
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 |
$address = new Address(); |
4 | 4 |
$list = $address->getList(); |
5 | 5 |
|
6 |
- $count = 0; |
|
6 |
+// $count = 0; |
|
7 | 7 |
?> |
8 | 8 |
<!doctype html> |
9 | 9 |
<html lang="ko"> |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?