001.
<html lang=
"en"
><head><meta http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
002.
<meta charset=
"utf-8"
>
003.
<title>แก้ไขข้อมูลอุปกรณ์</title>
004.
005.
<?php
006.
if
(!isset(
$_SESSION
)){
007.
session_start();
008.
}
009.
include_once
'include/function.php'
;
010.
011.
include_once
'include/connect.php'
;
012.
013.
$id
=
array
(
014.
'id'
=>
$_GET
[
'id'
],
015.
);
016.
$errorpost
=
'no'
;
017.
$result
=
$con
->prepare(
"SELECT * FROM equipment WHERE equ_id=:id"
);
018.
$result
->execute(
$id
);
019.
$rsn
=
$result
->fetch();
020.
021.
if
(isset(
$_POST
) && isset(
$_POST
[
'n'
])){
022.
if
(
$errorpost
==
'no'
){
023.
$n
=
$_POST
[
'n'
];
024.
025.
026.
027.
$result
=
$con
->prepare(
"UPDATE equipment SET type_id='"
.
$n
['type_id
']."'
,equ_name=
'".$n['
equ_name
']."'
,equ_num=
'".$n['
equ_num
']."'
"
028.
.
"WHERE equ_id='"
.
$n
['
$id
']."'
");
029.
$result
->execute();
030.
if
(
$result
!==FALSE){
031.
$_SESSION
[
'flash'
][
'msg'
]=
"บันทึกข้อมูลเรียบร้อย"
;
032.
$_SESSION
[
'flash'
][
'type'
]=
'success'
;
033.
redirect_to(
'admin_show_equ.php'
);
034.
}
else
{
035.
$_SESSION
[
'flash'
][
'msg'
]=
"บันทึกข้อมูลไม่ได้"
;
036.
$_SESSION
[
'flash'
][
'type'
]=
'danger'
;
037.
redirect_to(
'admin_show_equ.php'
);
038.
}
039.
}
040.
}
041.
042.
include_once
'include/header_a.php'
;
043.
?>
044.
<div
class
=
"container"
>
045.
<br>
046.
<br>
047.
048.
<?php
if
(isset(
$_SESSION
[
'flash'
])){?>
049.
<div
class
=
"alert alert-<?php echo $_SESSION['flash']['type'];?>"
role=
"alert"
><?php
echo
$_SESSION
[
'flash'
][
'msg'
]; ?></div>
050.
<?php }?>
051.
<div
class
=
"container"
>
052.
<img src=
"image/res.jpg"
style=
"width:480;"
alt=
""
/>
053.
054.
<div
class
=
"col-lg-6"
>
055.
<h3 id=
"tables"
class
=
"glyphicon glyphicon-plus-sign"
><b>แก้ไขอุปกรณ์</b></h3>
056.
057.
<div
class
=
"well"
style=
"width:640px;"
>
058.
<form method=
"post"
class
=
"form-horizontal"
enctype=
"multipart/form-data"
>
059.
<input type=
"hidden"
name=
"n[id]"
value=
"<?php echo $_GET['id']; ?>"
>
060.
<fieldset>
061.
<!--<legend></legend>-->
062.
<div
class
=
"form-group"
>
063.
<label
for
=
"equipment"
class
=
"col-lg-2 control-label"
>ชนิดอุปกรณ์</label>
064.
<div
class
=
"col-lg-10"
>
065.
<select name=
"n[type_id]"
id=
"type_id"
class
=
"form-control"
required=
"required"
>
066.
<option value=
"0"
hidden=
"hidden"
>กรุณาเลือก</option>
067.
<?php
068.
$resultsc
=
$con
->prepare(
"SELECT * FROM type_equ "
);
069.
$resultsc
->execute();
070.
while
(
$rssc
=
$resultsc
->fetch()){
071.
if
(
$rssc
[
'type_id'
] != 0) {
072.
echo
'<option value="'
.
$rssc
[
'type_id'
].
'"'
;
073.
if
(
$rssc
[
'type_id'
]==
$rsn
[
'type_id'
]){
074.
echo
'selected="selected"'
;
075.
}
076.
echo
'>'
.
$rssc
[
'type_name'
].
'</option>'
;
077.
}
078.
}
079.
?>
080.
</select>
081.
</div>
082.
</div>
083.
084.
085.
<div
class
=
"form-group"
>
086.
<label
for
=
"equ_name"
class
=
"col-lg-2 control-label"
>ชื่ออุปกรณ์</label>
087.
<div
class
=
"col-lg-10"
>
088.
<input type=
"text"
name=
"n[equ_name]"
id=
"equ_name"
class
=
"form-control"
placeholder=
"Name"
value=
"<?php echo $rsn['equ_name']; ?>"
required=
"required"
maxlength=
"50"
>
089.
</div>
090.
</div>
091.
<div
class
=
"form-group"
>
092.
<label
for
=
"equ_num"
class
=
"col-lg-2 control-label"
>จำนวน</label>
093.
<div
class
=
"col-lg-10"
>
094.
<input type=
"int"
name=
"n[equ_num]"
id=
"equ_num"
class
=
"form-control"
placeholder=
"Num"
value=
"<?php echo $rsn['equ_num']; ?>"
required=
"required"
maxlength=
"5"
>
095.
</div>
096.
</div>
097.
098.
<div
class
=
"form-group"
>
099.
<div
class
=
"col-lg-10 col-lg-offset-2"
>
100.
<input type=
"submit"
value=
"บันทึก"
class
=
"btn btn-primary"
>
101.
<a href=
"admin_show_equ.php"
class
=
"btn btn-warning"
value=
"ยกเลิก"
><b>ยกเลิก</b></a>
102.
</div>
103.
</div>
104.
</fieldset>
105.
</form>
106.
</div>
107.
</div>
108.
</div>
109.
<?php
110.
include_once
'include/footer.php'
;
111.
?>