-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewprob.php
executable file
·63 lines (46 loc) · 1.77 KB
/
viewprob.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
<?php include("includes/dashheader.php") ?>
<a href="problems.php">Back to Problem List</a>
<?php
include("connection.php");
$id = (int)$_GET["id"];
$query = mysqli_query($connect,"SELECT* FROM problems WHERE id='$id'");
$data = mysqli_fetch_array($query);
$rows = mysqli_num_rows($query);
if($rows == 0){
echo "<h1>The requested page cannot be found!</h1>";
} else {
?>
<h1><?php echo $data["title"] ?></h1>
<p><?php echo $data["description"] ?></p>
<div style="border:1px solid #c5c5c5;border-radius:5px;padding:15px;margin-bottom:10px;">
<h3>Contributions by other users</h3>
<?php
$refquery = mysqli_query($connect,"SELECT r.desc, u.fullname FROM `resources` AS r, `user` AS u WHERE r.pid='$id' AND u.id=r.uid ORDER BY datetime DESC LIMIT 3");
while($refdata = mysqli_fetch_array($refquery)){
echo "<p><b>".$refdata["fullname"]."</b><br/>".$refdata["desc"]."<br/></br/><a href='upvote.php' class='btn btn-primary'>Found this useful</a></p>";
}
?>
</div>
<div style="border:1px solid #c5c5c5;border-radius:5px;padding:15px;">
<form action="#" method="post">
<h3>Contribute to the issue</h3>
<div class="form-group">
<label for="prb_refs">Add knowledge, links, resources...</label>
<textarea class="form-control" name="less_refs" placeholder="Lesson References"></textarea>
</div>
<button name="less_submit" type="submit" class="btn btn-primary">Submit Reference</button>
</form>
<?php
if(isset($_POST["less_submit"])){
$refname = $_POST["less_refs"];
if(!empty($refname)){
$refname = mysqli_real_escape_string($connect,$refname);
mysqli_query($connect,"INSERT INTO `resources` (`id`, `pid`, `uid`, `desc`, `datetime`) VALUES (NULL, '$id', '$uid', '$refname', NOW());");
}
}
?>
</div>
<?php
}
?>
<?php include("includes/dashfooter.php") ?>