-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample4.php
182 lines (153 loc) · 4.68 KB
/
example4.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
require_once 'MiraQuotePHP/QuotesApiClient.php';
use MiraQuotePHP\QuotesApiClient;
$client = new QuotesApiClient('test'); // Your API key here
// Fetch multiple random quotes
try {
// Fetch wisdom quotes and number
$loveQuotes = $client->getRandomQuote('wisdom', null, 1); // Change number as desired
// Fetch quotes by author and number
$johnQuotes = $client->getRandomQuote(null, 'john', 2); // Change number as desired
} catch (Exception $e) {
$errorMessage = "Error: " . $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Quotes</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f0f8ff;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
text-align: center;
border: 2px solid #4a90e2;
border-radius: 10px;
padding: 20px;
background-color: white;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
width: 90%;
max-width: 600px;
overflow: hidden; /* Ensures no overflow on smaller screens */
}
.title {
font-size: 2rem;
color: #4a90e2;
}
.quote-text {
font-size: 1.5rem;
font-style: italic;
color: #333;
}
.author-text {
font-size: 1.2rem;
margin-top: 10px;
color: #666;
}
.btn {
padding: 10px 20px;
font-size: 1rem;
color: white;
background-color: #4a90e2;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
margin-top: 20px;
display: inline-block;
}
.btn:hover {
background-color: #357ABD;
}
/* Media Queries for Responsiveness */
@media (max-width: 768px) {
.title {
font-size: 1.5rem; /* Adjust title size for smaller screens */
}
.quote-text {
font-size: 1.2rem; /* Adjust quote size */
}
.author-text {
font-size: 1rem; /* Adjust author size */
}
.btn {
font-size: 0.9rem; /* Adjust button size */
}
}
/* Remove default bullets from lists */
ul {
list-style-type: none; /* Remove bullets */
padding: 0; /* Remove padding */
margin: 0; /* Remove margin */
}
@media (max-width: 480px) {
.container {
padding: 10px; /* Reduce padding on very small screens */
}
.title {
font-size: 1.2rem; /* Further adjust title size */
}
.quote-text {
font-size: 1rem; /* Further adjust quote size */
}
.author-text {
font-size: 0.9rem; /* Further adjust author size */
}
.btn {
padding: 8px 16px; /* Adjust button padding */
font-size: 0.8rem; /* Further adjust button size */
}
}
</style>
</head>
<body>
<div class="container">
<h1 class="title">Random Quotes</h1>
<h2>Love Quotes:</h2>
<div class="quote-box">
<?php if (!empty($loveQuotes)): ?>
<ul>
<?php foreach ($loveQuotes as $quote): ?>
<li class="quote-text">
"<?php echo htmlspecialchars($quote['quote'] ?? 'No quote'); ?>"
<br>
<span class="author-text"><?php echo htmlspecialchars($quote['author'] ?? 'Unknown author'); ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>No love quotes found.</p>
<?php endif; ?>
</div>
<h2>Quotes by John:</h2>
<div class="quote-box">
<?php if (!empty($johnQuotes)): ?>
<ul>
<?php foreach ($johnQuotes as $quote): ?>
<li class="quote-text">
"<?php echo htmlspecialchars($quote['quote'] ?? 'No quote'); ?>"
<br>
<span class="author-text"><?php echo htmlspecialchars($quote['author'] ?? 'Unknown author'); ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>No quotes by John found.</p>
<?php endif; ?>
</div>
<form method="post" action="">
<button type="submit" class="btn">Get New Quotes</button>
</form>
</div>
</body>
</html>