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

[สอนเขียน 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...

การดึงข้อมูล MySQL มาแสดงในปฏิทิน Fullcalendar ด้วย PHP

หลักการทำงาน เรียกข้อมูลจากตาราง tb_event ด้วยฟังก์ชั่นของ MySQLi ข้อมูลจากฐานข้อมูลจะถูกวนลูปเก็บไว้ใน $data และจะถูกส่งไปที่ Fullcalendar ด้วยการแปลงข้อมูลจาก PHP ให้อยู่ในรูปแบบ JSON อาร์เรย์ด้วยฟังก์ชั่น json_encode() PHP Code <?php //Database $data = array(); $link = mysqli_connect("127.0.0.1", "tobedev", "1234", "tobedev_example"); mysqli_set_charset($link, 'utf8'); if (!$link) {     echo "Error: Unable to connect to MySQL." . PHP_EOL;     echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;     echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;     exit; } $query = "SELECT * FROM tb_event"; if ($result = $link->query($query)) {     /* fetch object array */     while ($obj = $result->fetch_object()) {        $data[] = array(                 ...