-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
44 lines (37 loc) · 1.08 KB
/
functions.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
<?php
global $conn;
function getTableData($table){
global $conn, $get_data, $row;
$query = "SELECT * FROM $table ORDER BY id DESC LIMIT 0, 10";
$get_data = mysqli_query($conn, $query);
if (!$get_data) {
echo 'MySQL Error: ' . mysqli_error($conn);
exit;
}
// return $get_data;
$row = mysqli_fetch_assoc($get_data);
return $row;
;
}
function getDynamicData($table, $column, $id){
global $conn, $get_data, $row;
$query = "SELECT $column FROM $table WHERE id = $id";
$get_data = mysqli_query($conn, $query);
if (!$get_data) {
echo 'MySQL Error: ' . mysqli_error($conn);
exit;
}
$row = mysqli_fetch_assoc($get_data);
return $row[$column];
global $column;
}
function get_header($id){
$dyndat = getDynamicData('posts', 'header', $id);
echo $dyndat; //'<br><div class="head">' . $dyndat . '</div>';
}
function get_post($id){
$header = get_header($id);
$dyndat = getDynamicData('posts', 'post', $id);
echo $header . " " . $dyndat; //'<br><div class="post">' . $dyndat . '</div>';
}
?>