blob: d98b08be7666406a15ce7d8cc3824b53dce7492a (
plain)
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
|
<?php
class Category {
public $id = 0;
public $name = 'Unknown';
public $description = 'This category does not exist';
public $thread_count = 0;
public $post_count = 0;
function get_from_database($id, $dbc) {
$sql = "SELECT cat_name, cat_description, cat_thread_count, cat_post_count FROM categories WHERE cat_id = " . mysqli_real_escape_string($dbc, $id);
$result = mysqli_query($dbc, $sql);
if (!$result) {
echo 'Failed to get category: ' . mysqli_error($dbc);
}
if (mysqli_num_rows($result) == 0) {
echo 'Category does not exist!';
} else {
while ($row = mysqli_fetch_assoc($result)) {
$this->id = $id;
$this->name = $row['cat_name'];
$this->description = $row['cat_description'];
$this->thread_count = $row['cat_thread_count'];
$this->post_count = $row['cat_post_count'];
}
}
mysqli_free_result($result);
}
function get_threads() {
}
}
|