-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_data_select.php
More file actions
68 lines (68 loc) · 2.35 KB
/
load_data_select.php
File metadata and controls
68 lines (68 loc) · 2.35 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
//load_data_select.php
$connect = mysqli_connect("localhost", "root", "", "zzz");
function fill_brand($connect)
{
$output = '';
$sql = "SELECT * FROM brand";
$result = mysqli_query($connect, $sql);
while($row = mysqli_fetch_array($result))
{
$output .= '<option value="'.$row["brand_id"].'">'.$row["brand_name"].'</option>';
}
return $output;
}
function fill_product($connect)
{
$output = '';
$sql = "SELECT * FROM product";
$result = mysqli_query($connect, $sql);
while($row = mysqli_fetch_array($result))
{
$output .= '<div class="col-md-3">';
$output .= '<div style="border:1px solid #ccc; padding:20px; margin-bottom:20px;">'.$row["product_name"].'';
$output .= '</div>';
$output .= '</div>';
}
return $output;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Webslesson Tutorial | Multiple Image Upload</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<br /><br />
<div class="container">
<h3>
<select name="brand" id="brand">
<option value="">Show All Product</option>
<?php echo fill_brand($connect); ?>
</select>
<br /><br />
<div class="row" id="show_product">
<?php echo fill_product($connect);?>
</div>
</h3>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$('#brand').change(function(){
var brand_id = $(this).val();
$.ajax({
url:"load_data.php",
method:"POST",
data:{brand_id:brand_id},
success:function(data){
$('#show_product').html(data);
}
});
});
});
</script>