-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
68 lines (57 loc) · 1.62 KB
/
index.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
<?php
require_once __DIR__.'/curl/curl.php';
$curl = new MyCurl();
////use curl function with object serialization
if(file_exists("feed.php")) {
$rss = $curl->getWithDecode("http://localhost/phpprojects/rss-reader-php/feed.php");
$rss_feed = simplexml_load_string($rss);
echo $rss_feed;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>RSS Feed</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="selection-container">
<h4>RSS Feed</h4>
<!-- form with select input that is getting filled with feeds -->
<div>
<form action="" method="post" name="feedform">
<select name="feedoption" id="feedoption">
<option selected disabled>Please select one option</option>
<?php
if(!empty($rss_feed)) {
$i=0;
foreach ($rss_feed->channel->item as $feed_item) {
echo "<option value='".$i."'>".$feed_item->title."</option>";
$i += 1;
}
}
?>
</select>
</form>
</div>
<!-- feed page content -->
<div id="show"></div>
<script>
//AJAX function
$('#feedoption').on('change', function (e) {
e.preventDefault();
$.ajax({
type: 'post',
url: 'reader.php',
data: $('#feedoption').serialize(),
success : function(returnData) {
var show = returnData;
$('#show').html(show);
}
});
});
</script>
</body>
</html>