-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_bus.php
48 lines (48 loc) · 1.44 KB
/
manage_bus.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
include('db_connect.php');
if(isset($_GET['id']) && !empty($_GET['id']) ){
$qry = $conn->query("SELECT * FROM bus where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $val){
$meta[$k] = $val;
}
}
?>
<div class="container-fluid">
<form id="manage_bus">
<div class="col-md-12">
<div class="form-group mb-2">
<label for="name" class="control-label">Bus Name</label>
<input type="hidden" class="form-control" id="id" name="id" value='<?php echo isset($_GET['id']) ? $_GET['id'] : '' ?>' required="">
<input type="text" class="form-control" id="name" name="name" required="" value="<?php echo isset($meta['name']) ? $meta['name'] : '' ?>">
</div>
<div class="form-group mb-2">
<label for="bus_number" class="control-label">Bus Number</label>
<input type="number" class="form-control" id="bus_number" name="bus_number" required value="<?php echo isset($meta['bus_number']) ? $meta['bus_number'] : '' ?>">
</div>
</div>
</form>
</div>
<script>
$('#manage_bus').submit(function(e){
e.preventDefault()
start_load()
$.ajax({
url:'./save_bus.php',
method:'POST',
data:$(this).serialize(),
error:err=>{
console.log(err)
end_load()
alert_toast('An error occured','danger');
},
success:function(resp){
if(resp == 1){
end_load()
$('.modal').modal('hide')
alert_toast('Data successfully saved','success');
load_bus()
}
}
})
})
</script>