-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.php
103 lines (86 loc) · 3.36 KB
/
product.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Created by PhpStorm.
* User: tugceakin
* Date: 11/13/15
* Time: 2:12 AM
*/
$product_id = $_GET['product_id'];
// = get_product($product_id);
$dsn = 'mysql:host=localhost;dbname=online_market';
$username = 'root';
$password = 'password';
$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$db = new PDO($dsn, $username, $password, $options);
$query = "SELECT * FROM Products WHERE id = '$product_id'";
$product = $db->query($query)->fetch();
$query_counter = "UPDATE Products SET visit_count = visit_count + 1 WHERE id = '$product_id'";
$db->query($query_counter);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("view/header.php"); ?>
</head>
<body>
<?php include("view/navigation.php"); ?>
<div class="container">
<h1 style="text-align:center"><?php echo $product['title']; ?></h1>
<h2 style="text-align:center">Company: <?php echo $product['company']; ?></h2>
<p style="text-align:center;"><img align="middle" src="<?php echo $product['image_link']; ?>" ></p>
<p style="text-align:center;"><?php echo $product['body']; ?></p>
</div>
<div class="container">
<form class="form-horizontal center" id="savecomment" method='POST' action=''>
<fieldset style="text-align:center">
<h3>Add/Edit Comment</h3>
<input type="hidden" name="artwork_id" value="<?php echo $artwork_id; ?>">
<div>
<label class="radio-inline">
<input type="radio" checked name="rating" id="inlineRadio1" value="1"> 1
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="inlineRadio2" value="2"> 2
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="inlineRadio3" value="3"> 3
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="inlineRadio3" value="4"> 4
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="inlineRadio3" value="5"> 5
</label>
</div>
<div class="col-md-offset-3 col-md-6">
<input id="input-21d" value="2" type="number" class="rating" min=0 max=5 step=1 data-size="sm">
<div class="control-group">
<label for="comment">Comment:</label>
<textarea class="form-control" cols="2" rows="5" name="comment" id="comment"></textarea>
</div>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<?php if(!isset($_SESSION)) :?>
<button type="button" name="submit" value ="Save" class="btn btn-success btn-sm save-comment" >Save Comment</button>
<?php else :?>
<button type="submit" name="submit" value ="Save" class="btn btn-success btn-sm" >Save Comment</button>
<?php endif;?>
</div>
</div>
</fieldset>
</form>
</div>
<script src="lib/lib/jquery/dist/jquery.min.js")"></script>
<script src="lib/lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="lib/lib/star-rating.min.js"></script>
<script src="lib/lib/DataTables-1.10.7/media/js/jquery.dataTables.min.js"></script>
<script src="lib/lib/main.js"></script>
<script>
$('#input-21d').on('rating.change', function(event, value, caption) {
console.log(value);
console.log(caption);
});
</script>
</body>
</html>