ข้ามไปที่เนื้อหาหลัก

[สอนเขียน PHP] สร้าง PHP Builder ตอนที่ 2 : ดาวน์โหลดและติดต้ง Bootstrap Template

มาเลือกเทมเพลตสำหรับโปรเจ็กต์กันก่อนเลยครับ ^O^
 

สำหรับ Bootstrap Template ที่ผมเลือกใช้ในวิดีโอนี้ก็คือ

SB Admin 2

http://startbootstrap.com/template-overviews/sb-admin-2/

ลองดาวน์โหลด และนำมาใช้งานกันดูนะครับ ^^


#Edit

สาเหตุที่ในคลิปวิดีโอไม่สามารถใช้ตัวพิมพ์เล็กบน URL ของ Controller ได้นั้น ไม่ได้เกี่ยวกับระบบ Ubuntu แต่อย่างใด

สาเหตุเกิดจากไฟล์ application/third_party/MX/Rounter.php ยังเป็นฟังก์ชั่นเก่าที่ใช้กับเวอร์ชั่น 2.x ที่ไม่ได้สนใจชื่อไฟล์ตัวแรกเล็กหรือใหญ่ให้แก้ไขฟังก์ชั่น locate ดังโค๊ดด้านล่างนี้ครับ



/** Locate the controller **/
    public function locate($segments) {      
      
        $this->module = '';
        $this->directory = '';
        $ext = $this->config->item('controller_suffix').EXT;
      
        /* use module route if available */
        if (isset($segments[0]) AND $routes = Modules::parse_routes($segments[0], implode('/', $segments))) {
            $segments = $routes;
        }
   
        /* get the segments array elements */
        list($module, $directory, $controller) = array_pad($segments, 3, NULL);

        /* check modules */
        foreach (Modules::$locations as $location => $offset) {
      
            /* module exists? */
            if (is_dir($source = $location.$module.'/controllers/')) {
              
                $this->module = $module;
                $this->directory = $offset.$module.'/controllers/';
              
                /* module sub-controller exists? */
                if($directory AND is_file($source.$directory.$ext)) {
                    return array_slice($segments, 1);
                }
                  
                /* module sub-directory exists? */
                if($directory AND is_dir($source.$directory.'/')) {

                    $source = $source.$directory.'/';
                    $this->directory .= $directory.'/';

                    /* module sub-directory controller exists? */
                    if(is_file($source.$directory.$ext)) {
                        return array_slice($segments, 1);
                    }
              
                    /* module sub-directory sub-controller exists? */
                    if($controller AND is_file($source.$controller.$ext))    {
                        return array_slice($segments, 2);
                    }
                }
              
                /* module controller exists? */          
                if(is_file($source.$module.$ext)) {
                    return $segments;
                }
            }
        }
      
        /* application controller exists? */          
        if (is_file(APPPATH.'controllers/'. ucfirst($module) .$ext)) {
            return $segments;
        }
      
        /* application sub-directory controller exists? */
        if($directory AND is_file(APPPATH.'controllers/'.ucfirst($module).'/'.$directory.$ext)) {
            $this->directory = $module.'/';
            return array_slice($segments, 1);
        }
      
        /* application sub-directory default controller exists? */
        if (is_file(APPPATH.'controllers/'.$module.'/'.ucfirst($this->default_controller).$ext)) {
            $this->directory = $module.'/';
            return array(ucfirst($this->default_controller));
        }
    }


ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

แจกฟรี!! ระบบต่างๆที่พัฒนาด้วย PHP สำหรับนำไปใช้ในงานต่างๆ

       สำหรับหลายท่านที่ขอโค้ดเข้ามาทาง Inbox ของเฟซบุ๊กแฟนเพจ หรือถามถึงระบบต่างๆหลังไมค์มานั้น ส่วนใหญ่ก็มีแจกอยู่แล้วในเว็บบอร์ด ThaiCreate.Com นะครับ และด้านล่างนี้ก็เป็นระบบต่างๆที่แจกให้นำไปลองใช้ลองศึกษากันครับ

สอนเขียน PHP แสดงการจองห้องประชุมแบบไฮไลท์ตามช่วงเวลา (แบบเชื่อมต่อฐานข้อมูล MySQL)

ตัวอย่าง ผลลัพธ์ที่ได้จากการจองในฐานข้อมูล ตาราง tb_room สร้างตารางรายชื่อห้องประชุม สำหรับ id นั้นเป็น Primarykey จะกำหนดให้สร้างอัตโนมัติ ทุกครั้งที่เราเพิ่มชื่อห้องประชุมใหม่ -- -- Database: `tobedev_example` -- -- -------------------------------------------------------- -- -- Table structure for table `tb_room` -- CREATE TABLE IF NOT EXISTS `tb_room` (   `id` int(11) NOT NULL,   `name` varchar(30) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_room` -- INSERT INTO `tb_room` (`id`, `name`) VALUES (1, 'ห้องประชุม 1'), (2, 'ห้องประชุม 2'), (3, 'ห้องประชุม 3'), (4, 'ห้องประชุม 4'), (5, 'ห้องประชุม 5'); -- -- Indexes for dumped tables -- -- -- Indexes for table `tb_room` -- ALTER TABLE `tb_room`   ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tb_room` -- ALTER TABLE `tb_room`   MODIFY `i...

PHP กับการคิดส่วนลดเป็นเปอร์เซ็น 5%, 10%, 20% ตามช่วงราคาที่กำหนด

<?php     $total_price = 1000;     $discount = 0;         if($total_price >= 500 && $total_price < 1001){         $discount = 5;     }elseif($total_price >= 1001 && $total_price <= 5000){         $discount = 10;     }elseif($total_price >= 5001){         $discount = 20;     }         $discount_bath = ($total_price*$discount)/100; ?> <pre> ซื้อสินค้าครบ 0 ถึง 499 บาท ไม่ได้ส่วนลด ซื้อสินค้าครบ 500 ถึง 1000 บาท ได้ส่วนลด 5% ซื้อสินค้าครบ 1001 ถึง 5000บาท ได้ส่วนลด 10% ซื้อสินค้าครบ 5001 บาทขึ้นไป ได้ส่วนลด 20% </pre> <h3>รวมราคาสินค้า = <?php echo number_format($total_price,2);?></h3> <h5>ส่วนลด = <?php echo $discount;?>%  (<?php echo $discount_bath;?...