-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfact.php
More file actions
75 lines (60 loc) · 1.98 KB
/
fact.php
File metadata and controls
75 lines (60 loc) · 1.98 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
69
70
71
72
73
74
75
<?php
include("header.php");
include("config.php");
$id = $_GET["id"];
$query = "SELECT * FROM wikitour WHERE id=$id";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$fact = $row[fact];
$source = $row[source];
$likes = $row[likes];
?>
<script>
$.getJSON("http://en.wikipedia.org/w/api.php?action=parse&format=json&callback=?",
{
page:"<?php echo $source; ?>", prop:"text"
}, function(data) {
var content = data.parse.text['*'];
content = content.replace(/href=\"\/wiki\//g, "href=\"wikipedia.php?source=");
$("#wikiText").html(content);
});
</script>
<p id="factText"><?php echo $fact; ?></p>
<div id="wikiText">
</div>
<div data-role="footer" data-position="fixed" style="padding:3px;">
<a href="index.php" data-role="button" data-rel="back" data-ajax="false" data-icon="arrow-l">Home</a>
<button type="submit" id="like_button" data-icon="check" value="Like"></button>
<!--//$("#like_image").attributes("src","like2.png");
//<input type="button" img><id="like_image" src="like1.png"></input>-->
<a href="wikipedia.php?source=<?php echo $source; ?>" data-role="button" data-icon="arrow-r" style="float:right;">Wiki Page</a>
</div>
<script>
function handleClick(e) {
var target = $(e.target).closest('a');
if( target ) {
e.preventDefault();
window.location = target.attr('href');
}
}
$('#like_button').click( function() {
if ($('#like_button').attr("data-theme") != "b") {
$('#like_button').buttonMarkup({theme: "b"});
<?php
$update1 = "UPDATE wikitour SET likes = likes + 1 WHERE id=$id";
echo "console.log('increment up by one');";
$result = mysql_query($update1);
echo "console.log('$result');";
?>
} else {
$('#like_button').buttonMarkup({theme: "a"});
<?php
$update1 = "UPDATE wikitour SET likes = likes - 1 WHERE id=$id";
echo "console.log('increment down to 1');";
$result= mysql_query($update1);
echo "console.log('$result');";
?>
}
});
</script>
<?php include('footer.php'); ?>