/home/nondinda/domains/nondindaengcity.go.th/public_html/php_webboard_v1/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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
session_start
();
require(
'bin/connectdb.php');
//แสดงหมวดหมุ่กระทู้ทั้งหมดโดยเรียงตามลำดับ cg_order จากน้อยไปมาก
$rs_category mysql_query("SELECT * FROM tbl_category ORDER BY cg_order ASC");
$chk_rows_category mysql_num_rows($rs_category); //นับจำนวนแถวของหมวดกระทู้
?>
<html>
    <head>
        <?php require('head.php'); ?>
        <title>สอนทำเว็บบอร์ดด้วย PHP + MySQL + Bootstrap</title>
    </head>
    <body>
        <?php require('menu.php'); ?>
        <div class="container">
            <?php require('header.php'); ?>
            <div class="row ws-content">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>หมวดกระทู้</th><th class="hidden-xs">หัวข้อกระทู้</th>
                            <th class="hidden-xs">ความคิดเห็น</th></tr>
                    </thead>
                    <tbody>
                        <?php
                        
if ($chk_rows_category 0) {//จำนวนแถวมากกว่า 0 แสดงว่ามีข้อมูล
                            
while ($show_category mysql_fetch_assoc($rs_category)) {
                                
$cg_id $show_category['cg_id'];
                                
$cg_name $show_category['cg_name'];
                                
$cg_des $show_category['cg_des'];
                                
$cg_v $show_category['cg_replie_totals'];
                                
$cg_tp_total $show_category['cg_topic_totals'];
                                
?>
                                <tr>
                                    <td style="width:80%">
                                        <a href="showboard.php?id=<?php echo $cg_id?>"><?php echo $cg_name?></a>
                                        <br /><?php echo $cg_des?>
                                    </td>
                                    <td style="width:10%" class="hidden-xs"><?php echo $cg_tp_total?></td>
                                    <td style="width:10%" class="hidden-xs"><?php echo $cg_v?></td>
                                </tr>
                                <?php
                            
}
                        } else { 
//ไม่มีข้อมูลหมวดกระทู้
                            
?>
                            <tr>
                                <td colspan="3" align="center"><strong>ไม่พบข้อมูล</strong></td>
                            </tr>
                        <?php ?>
                    </tbody>
                </table>
            </div>
            <?php require('footer.php'); ?>
        </div>      
    </body>
</html>
</body>
</html>