CRUD Buster

Derek Jones edited this page Jul 5, 2012 · 7 revisions
Clone this wiki locally

Category:Library | Category:Library::Community | Category:Library::CodeGenerators This will generate CRUD code and output to one single page. All you need to do is copy/paste the code blocks in each appropriate file and you're set!

libraries/CRUD_Buster.php


<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/*****
  * Code_Generator quickly creates CRUD forms
  * @author     KMScreative
  * @email      webmaster@kmscreative.com
  * @filename   CRUD_Buster.php
  * @title      CRUD_Buster
  * @url        http://www.kmscreative.com/
  * @version    1.0
  *****/
 
class CRUD_Buster {
 
    var $CI;
    
    function __construct()
    {
        $this->CI =& get_instance();
    }
    
    function output_controller_code()
    {
        $this->CI->data['field_list'] = $this->CI->input->xss_clean($_POST['field_list']);
        $this->CI->data['description_list'] = $this->CI->input->xss_clean($_POST['description_list']);
        $data_type = strtolower($this->CI->input->xss_clean($_POST['data_type']));
        $field_type = strtolower($this->CI->input->xss_clean($_POST['field_type']));
        $database_table = $this->CI->input->xss_clean($_POST['database_table']);
        $dbfield_type = strtolower($this->CI->input->xss_clean($_POST['dbfield_type']));
        
        $controller_name = ucfirst($data_type); // Ex: Post
        if ($controller_name[strlen($controller_name)-1] == "y")
        {
            $controller_name_mod = $controller_name;
            $controller_name_mod[strlen($controller_name_mod)-1] = "i";
            $pl_controller_name = $controller_name_mod."es"; // Ex: Companies
        }
        else
        {
            $pl_controller_name = $controller_name."s"; // Ex: Posts
        }
        $model_name = $controller_name."_model"; // Ex: Post_model
        $lc_controller_name = strtolower($controller_name); // Ex: post
        $field_type_id = $lc_controller_name."_id"; // Ex: post_id
        
        $controller_file_name = "controllers/".$data_type.".php"; // Ex: controllers/post.php
        $model_file_name = "models/".$data_type."_model.php"; // Ex: models/post_model.php
        $view_add_base = $data_type."/".$data_type; // Ex: post/post
        $view_all_file_name = "views/".$view_add_base."_view_all.php"; // Ex: views/view_view_all.php
        $view_add_file_name = "views/".$view_add_base."_add_".$data_type.".php"; // Ex: views/view_add_view.php
        $view_edit_file_name = "views/".$view_add_base."_edit_".$data_type.".php"; // Ex: views/view_edit_view.php
        $view_delete_file_name = "views/".$view_add_base."_delete_".$data_type.".php"; // Ex: views/view_delete.php
        $view_delete_base = "delete".$lc_controller_name."_confirmed"; // Ex: deletepost_confirmed
        
        $add_to_model = "\$this->".$controller_name."_model->add".$controller_name."();"; // Ex: $this->Post_model->addPost();
        $edit_to_model = "\$this->".$controller_name."_model->edit".$controller_name."();"; // Ex: $this->Post_model->editPost();
        
        $add_to_view = "\$this->template->load('mainTemplate', '".$view_add_base."_add_".$data_type."', \$data);"; // Ex: $this->template->load('mainTemplate', 'post/post_add_post', $data);
        $add_to_view_success = "\$this->template->load('mainTemplate', 'common/blank', \$data);"; // Ex: $this->template->load('mainTemplate', 'common/blank', $data);
        $edit_to_view = "\$this->template->load('mainTemplate', '".$view_add_base."_edit_".$data_type."', \$data);"; // Ex: $this->template->load('mainTemplate', 'post/post_add_post', $data);
        
        $fieldName_array = explode("|",$this->CI->data['field_list']);
        $fieldDesc_array = explode("|",$this->CI->data['description_list']);
        $fieldType_array = explode("|",$field_type);
        $dbfieldType_array = explode("|",$dbfield_type);
        
        $code = <<<EOD

<table>
&lt;form&gt;

<strong>MySQL:</strong><br /><br />
&lt;textarea name="code" rows="10" cols="100" id="myCpWindow9" class="codepress sql linenumbers-on"&gt;
USE database_name;
CREATE TABLE table_name
(

EOD;

        $i = 1;
        foreach ($dbfieldType_array as $df)
        {
            if ($i < count($dbfieldType_array))
            {
                $code .= "&nbsp;&nbsp;".$df.",\n";
            }
            elseif ($i = count($dbfieldType_array))
            {
                $code .= "&nbsp;&nbsp;".$df."\n";
            }
            $i++;
        }

        $code .= <<<EOD
);
&lt;/textarea&gt;

<br /><br />
<strong>Controller:</strong> $controller_file_name<br /><br />
&lt;textarea name="code" rows="25" cols="100" id="myCpWindow1" class="codepress php linenumbers-on"&gt;
&lt;?php

class $controller_name extends Controller {
    
&nbsp;&nbsp;&nbsp;&nbsp;function $controller_name()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::Controller();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->load->library('session');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//\$this->output->enable_profiler(TRUE);
&nbsp;&nbsp;&nbsp;&nbsp;}\n
&nbsp;&nbsp;&nbsp;&nbsp;function view()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( !\$this->session->userdata('logged_in') )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect('user/login/', 'location');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( \$this->uri->segment(3) == NULL )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect('$lc_controller_name/view/all/', 'location');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( \$this->uri->segment(3) == "all" )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->load->library('pagination');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['base_url'] = base_url() . '{$lc_controller_name}/view/all/';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['total_rows'] = \$this->db->count_all('$database_table');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['uri_segment'] = '4';
                
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['per_page'] = '10';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['num_links'] = '4';
                
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['full_tag_open'] = '<ul id="dbresultsnav" class="clearfix">';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['full_tag_close'] = '</ul>';
        
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['cur_tag_open'] = '<li id="dbresultsnav"><a id="dbresultsnav">';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['cur_tag_close'] = '</a></li>';

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['main_link_open'] = '<li id="dbresultsnav">';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['main_link_close'] = '</li>';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['main_link_class'] = 'id="dbresultsnav"';
    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['main_curlink_open'] = '<li id="dbresultsnavcur">';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['main_curlink_close'] = '</li>';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$config['main_curlink_class'] = 'id="dbresultsnavcur"';                
                
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->pagination->initialize(\$config); 

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$num = \$config['per_page'];
                
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (\$this->uri->segment(4) != NULL)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$offset = \$this->uri->segment(4);    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$offset = 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
                
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['pagination'] = \$this->pagination->create_links();
                
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->load->model('$model_name', '', TRUE);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['All$pl_controller_name'] = \$this->{$model_name}->findAll{$pl_controller_name}(\$num,\$offset);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['head_title'] = 'My Site - View All $pl_controller_name';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->template->load('mainTemplate', '$lc_controller_name/{$lc_controller_name}_view_all', \$data);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect('user/profile/', 'location');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}        
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;function add()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( !\$this->session->userdata('logged_in') )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect('user/login/', 'location');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$rules = array(\n
EOD;

        $i = 1;
        foreach ($fieldName_array as $f)
        {
            if ($i < count($fieldName_array))
            {
                if ($f == "email")
                {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$f."' => \"trim|valid_email|xss_clean\",\n";
                }
                else
                {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$f."' => \"trim|xss_clean\",\n";
                }
            }
            elseif ($i = count($fieldName_array))
            {
                $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$f."' => \"trim|xss_clean\"\n";
            }
            $i++;
        }
        
        $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$fields = array(\n
EOD;

        $i = 1;
        foreach ($fieldDesc_array as $d)
        {
            if ($i < count($fieldDesc_array))
            {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$fieldName_array[$i-1]."' => \"".$d."\",\n";
            }
            elseif ($i = count($fieldDesc_array))
            {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$fieldName_array[$i-1]."' => \"".$d."\"\n";
            }
            $i++;
        }

        $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\n
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->validation->set_rules(\$rules);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->validation->set_fields(\$fields);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->validation->set_error_delimiters('<div class="error">', '</div>');\n
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (\$this->input->post('submit'))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (\$this->validation->run() == FALSE)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['head_title'] = 'My Site - Add $controller_name';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$add_to_view
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->load->model('$model_name', '', TRUE);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['query'] = $add_to_model
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$add_to_view_success
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['head_title'] = 'My Site - Add $controller_name';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$add_to_view
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;function edit()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( !\$this->session->userdata('logged_in') )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect('user/login/', 'location');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$rules = array(\n
EOD;

        $i = 1;
        foreach ($fieldName_array as $f)
        {
            if ($i < count($fieldName_array))
            {
                if ($f == "email")
                {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$f."' => \"trim|valid_email|xss_clean\",\n";
                }
                else
                {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$f."' => \"trim|xss_clean\",\n";
                }
            }
            elseif ($i = count($fieldName_array))
            {
                $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$f."' => \"trim|xss_clean\"\n";
            }
            $i++;
        }
        
        $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$fields = array(\n
EOD;

        $i = 1;
        foreach ($fieldDesc_array as $d)
        {
            if ($i < count($fieldDesc_array))
            {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$fieldName_array[$i-1]."' => \"".$d."\",\n";
            }
            elseif ($i = count($fieldDesc_array))
            {
                    $code .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'".$fieldName_array[$i-1]."' => \"".$d."\"\n";
            }
            $i++;
        }

        $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\n
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->validation->set_rules(\$rules);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->validation->set_fields(\$fields);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->validation->set_error_delimiters('<div class="error">', '</div>');\n
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (\$this->input->post('submit'))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (\$this->validation->run() == FALSE)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['head_title'] = 'My Site - Edit $controller_name';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$edit_to_view
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->load->model('$model_name', '', TRUE);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['query'] = $edit_to_model
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$add_to_view_success
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$data['head_title'] = 'My Site - Edit $controller_name';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$edit_to_view
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}

}

?&gt;
&lt;/textarea&gt;

<br /><br />
<strong>Model:</strong> $model_file_name<br /><br />
&lt;textarea name="code" rows="25" cols="100" id="myCpWindow2" class="codepress php linenumbers-on"&gt;
&lt;?php

class $model_name extends Model {
    
&nbsp;&nbsp;&nbsp;&nbsp;function $model_name()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::Model();
&nbsp;&nbsp;&nbsp;&nbsp;}
    
&nbsp;&nbsp;&nbsp;&nbsp;function add$controller_name()
&nbsp;&nbsp;&nbsp;&nbsp;{\n
EOD;

        $i = 1;
        foreach ($fieldType_array as $t)
        {
            $fn = $fieldName_array[$i-1];
            $fd = $fieldDesc_array[$i-1];
            
        $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->data['$fn'] = \$this->input->xss_clean(\$_POST['$fn']);\n
EOD;

            $i++;
        }

        $code .= <<<EOD
\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->insert('$database_table', \$this->data);
&nbsp;&nbsp;&nbsp;&nbsp;}\n
&nbsp;&nbsp;&nbsp;&nbsp;function edit$controller_name()
&nbsp;&nbsp;&nbsp;&nbsp;{\n
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->data['$field_type_id'] = \$this->input->xss_clean(\$_POST['$field_type_id']);\n
EOD;

        $i = 1;
        foreach ($fieldType_array as $t)
        {
            $fn = $fieldName_array[$i-1];
            $fd = $fieldDesc_array[$i-1];
            
        $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->data['$fn'] = \$this->input->xss_clean(\$_POST['$fn']);\n
EOD;
            $i++;
        }

        $code .= <<<EOD
\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->insert('$database_table', \$this->data, array('$field_type_id' => \$this->data['$field_type_id']));
&nbsp;&nbsp;&nbsp;&nbsp;}\n
EOD;

        $code .= <<<EOD
\n&nbsp;&nbsp;&nbsp;&nbsp;function delete$controller_name($$field_type_id)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->delete('$database_table', array('$field_type_id' => $$field_type_id));    
        
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$messagedata = array(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'msg_text' => '$controller_name deleted successfully.',
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'msg_col' => 'MsgBkgGrn'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->session->set_userdata(\$messagedata);                
&nbsp;&nbsp;&nbsp;&nbsp;}
\n&nbsp;&nbsp;&nbsp;&nbsp;function findAll$pl_controller_name(\$limit = NULL, \$offset = NULL)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->select('*');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->from('$database_table');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->orderby("$field_type_id DESC");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->limit(\$limit, \$offset);
        
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$query = \$this->db->get();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return \$query;        
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;function displayThis$controller_name()
&nbsp;&nbsp;&nbsp;&nbsp;{    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->select('*');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->from('$database_table');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->where('job_id', \$this->uri->segment(3));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->limit(1);        
        
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$query = \$this->db->get();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return \$query;        
&nbsp;&nbsp;&nbsp;&nbsp;}    
    
\n&nbsp;&nbsp;&nbsp;&nbsp;function findThis$controller_name($$field_type_id)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->select('*');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->where('$field_type_id', \$this->uri->segment(3));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$this->db->limit(1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$query = \$this->db->get('$database_table');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return \$query;
&nbsp;&nbsp;&nbsp;&nbsp;}
}
?&gt;
&lt;/textarea&gt;

<br /><br />
<strong>View:</strong> $view_all_file_name<br /><br />
&lt;textarea name="code" rows="25" cols="100" id="myCpWindow10" class="codepress php linenumbers-on"&gt;
<h1>View $pl_controller_name</h1><br /><br />

&lt;?php
\$color1 = "odd"; 
\$color2 = "even"; 
\$row_count = 0;
?&gt;

<table>
 <tr>\n
EOD;

        $i = 1;
        foreach ($fieldDesc_array as $d)
        {
            if ($i <= count($fieldDesc_array))
            {
                    $code .= "&nbsp;&nbsp;<th>".$d."</th>\n";
            }
            $i++;
        }

        $code .= <<<EOD
 </tr>

 &lt;?php foreach(\$All{$pl_controller_name}->result() as \$rowAll{$pl_controller_name}): ?&gt;
 &lt;?php \$row_color = (\$row_count % 2) ? \$color1 : \$color2; ?&gt;
 <tr>
  <td class="&lt;?php echo \$row_color; ?&gt;">&lt;?php echo anchor('{$lc_controller_name}/view/'.\$rowAll{$pl_controller_name}->{$lc_controller_name}_id, \$rowAll{$pl_controller_name}->{$lc_controller_name}, array('class' => 'dbplink')); ?&gt;&nbsp;</td>
EOD;

        $i = 1;
        foreach ($fieldName_array as $f)
        {
            if ($i <= count($fieldName_array))
            {
                $code .= "&nbsp;&nbsp;<td class=\"&lt;?php echo \$row_color; ?&gt;\">&lt;?php echo \$rowAll{$pl_controller_name}->".$f."; ?&gt;&nbsp;</td>\n";
            }
            $i++;
        }

        $code .= <<<EOD
 </tr>
 &lt;?php \$row_count++; ?&gt;
 &lt;?php endforeach; ?&gt;

</table>

<br />

&lt;?php echo \$pagination; ?&gt;<br />

<a class="dbplink" href="&lt;?php echo base_url(); ?&gt;{$lc_controller_name}/add"><img src="&lt;?php echo base_url(); ?&gt;images/icons/add.png" alt="Add a New {$controller_name}" align="middle"></a>&nbsp;<a class="dbplink" href="&lt;?php echo base_url(); ?&gt;{$lc_controller_name}/add">Add a New {$controller_name}</a>
&lt;/textarea&gt;

<br /><br />
<strong>View:</strong> $view_add_file_name<br /><br />
&lt;textarea name="code" rows="25" cols="100" id="myCpWindow3" class="codepress php linenumbers-on"&gt;
<h1>Add a new $lc_controller_name</h1><br /><br />

<table>

&lt;?php echo form_open('$lc_controller_name/add'); ?&gt;\n\n
EOD;

        $i = 1;
        foreach ($fieldType_array as $t)
        {
            $fn = $fieldName_array[$i-1];
            $fd = $fieldDesc_array[$i-1];
            
            if ($i <= count($fieldType_array))
            {
                if ($t == "input")
                {                
                    $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="text" name="$fn" value="&lt;?php echo \$this-&gt;validation->value('$fn'); ?&gt;" size="50" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
                }
                elseif ($t == "checkbox")
                {
                    $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="text" name="$fn" value="&lt;?php echo \$this-&gt;validation->value('$fn'); ?&gt;" size="50" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
                }
                elseif ($t == "radio")
                {
                    $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="text" name="$fn" value="&lt;?php echo \$this-&gt;validation->value('$fn'); ?&gt;" size="50" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
                }
                elseif (($t == "dropdown") && ($fn == "state"))
                {
                    $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$choices_states = array('' => 'Select one:', 'AL'=>"Alabama", 'AK'=>"Alaska", 'AZ'=>"Arizona", 'AR'=>"Arkansas",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'CA'=>"California", 'CO'=>"Colorado", 'CT'=>"Connecticut", 'DE'=>"Delaware",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'DC'=>"District Of Columbia", 'FL'=>"Florida", 'GA'=>"Georgia", 'HI'=>"Hawaii",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ID'=>"Idaho", 'IL'=>"Illinois", 'IN'=>"Indiana", 'IA'=>"Iowa", 'KS'=>"Kansas",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'KY'=>"Kentucky", 'LA'=>"Louisiana", 'ME'=>"Maine", 'MD'=>"Maryland", 'MA'=>"Massachusetts",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'MI'=>"Michigan", 'MN'=>"Minnesota", 'MS'=>"Mississippi", 'MO'=>"Missouri",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'MT'=>"Montana", 'NE'=>"Nebraska", 'NV'=>"Nevada", 'NH'=>"New Hampshire",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'NJ'=>"New Jersey", 'NM'=>"New Mexico", 'NY'=>"New York", 'NC'=>"North Carolina",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ND'=>"North Dakota", 'OH'=>"Ohio", 'OK'=>"Oklahoma", 'OR'=>"Oregon",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'PA'=>"Pennsylvania", 'RI'=>"Rhode Island", 'SC'=>"South Carolina", 'SD'=>"South Dakota",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'TN'=>"Tennessee", 'TX'=>"Texas", 'UT'=>"Utah", 'VT'=>"Vermont", 'VA'=>"Virginia",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'WA'=>"Washington", 'WV'=>"West Virginia", 'WI'=>"Wisconsin", 'WY'=>"Wyoming");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo form_dropdown('state', \$choices_states, (\$this->input->post('state')) ? (\$this->input->post('state')) : '\$defaultValue'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
                }
                elseif (($t == "dropdown") && ($fn != "state"))
                {
                    $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$choices_{$fn}s = array('' => 'Select one:', 'Choice1'=>"Value1", 'Choice2'=>"Value2");    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo form_dropdown('{$fn}', \$choices_{$fn}s, (\$this->input->post('$fn')) ? (\$this->input->post('$fn')) : '\$defaultValue'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
                }                
            }
            $i++;
        }

        $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input name="submit" type="submit" id="submit" value="Submit" style="font-family:Verdana; font-size:8pt; font-weight:bold; color:#FFFFFF; height:20; background:#000066; border:1 solid #808080; cursor:hand"&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n
&lt;/form&gt;
</table>
&lt;/textarea&gt;

<br /><br />
<strong>View:</strong> $view_edit_file_name<br /><br />
&lt;textarea name="code" rows="25" cols="100" id="myCpWindow4" class="codepress php linenumbers-on"&gt;
<h1>Edit $lc_controller_name</h1><br /><br />

<table>

&lt;?php echo form_open('$lc_controller_name/edit'); ?&gt;\n
&lt;?php echo form_hidden('$field_type_id', \$this->uri->segment(3)); ?&gt;
&lt;?php echo form_hidden('modified_by', \$this->session->userdata('user_id')); ?&gt;
&lt;?php echo form_hidden('modified_on', date('Y-m-d h:i:s')); ?&gt;\n\n
EOD;

        $i = 1;
        foreach ($fieldType_array as $t)
        {
            $fn = $fieldName_array[$i-1];
            $fd = $fieldDesc_array[$i-1];
            
            if ($t == "input")
            {                
                $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="text" name="$fn" value="&lt;?php echo (\$this-&gt;validation->value('$fn')) ? (\$this->validation->value('$fn')) : (\$row->$fn);?&gt;" size="25" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
            }
            elseif ($t == "checkbox")
            {
                $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="text" name="$fn" value="&lt;?php echo \$this-&gt;validation->value('$fn'); ?&gt;" size="50" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
            }
            elseif ($t == "radio")
            {
                $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="text" name="$fn" value="&lt;?php echo \$this-&gt;validation->value('$fn'); ?&gt;" size="50" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
            }
            elseif (($t == "dropdown") && ($fn == "state"))
            {
                $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><span class="FormFieldTitle">$fd:</span></td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((isset($_POST)) AND (!\$this->input->post('state')))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "One must be selected<br />";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$choices_states = array('' => 'Select one:', 'AL'=>"Alabama", 'AK'=>"Alaska", 'AZ'=>"Arizona", 'AR'=>"Arkansas",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'CA'=>"California", 'CO'=>"Colorado", 'CT'=>"Connecticut", 'DE'=>"Delaware",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'DC'=>"District Of Columbia", 'FL'=>"Florida", 'GA'=>"Georgia", 'HI'=>"Hawaii",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ID'=>"Idaho", 'IL'=>"Illinois", 'IN'=>"Indiana", 'IA'=>"Iowa", 'KS'=>"Kansas",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'KY'=>"Kentucky", 'LA'=>"Louisiana", 'ME'=>"Maine", 'MD'=>"Maryland", 'MA'=>"Massachusetts",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'MI'=>"Michigan", 'MN'=>"Minnesota", 'MS'=>"Mississippi", 'MO'=>"Missouri",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'MT'=>"Montana", 'NE'=>"Nebraska", 'NV'=>"Nevada", 'NH'=>"New Hampshire",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'NJ'=>"New Jersey", 'NM'=>"New Mexico", 'NY'=>"New York", 'NC'=>"North Carolina",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ND'=>"North Dakota", 'OH'=>"Ohio", 'OK'=>"Oklahoma", 'OR'=>"Oregon",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'PA'=>"Pennsylvania", 'RI'=>"Rhode Island", 'SC'=>"South Carolina", 'SD'=>"South Dakota",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'TN'=>"Tennessee", 'TX'=>"Texas", 'UT'=>"Utah", 'VT'=>"Vermont", 'VA'=>"Virginia",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'WA'=>"Washington", 'WV'=>"West Virginia", 'WI'=>"Wisconsin", 'WY'=>"Wyoming");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php /* echo form_dropdown('state', \$choices_states, (\$this->input->post('state')) ? (\$this->input->post('state')) : '\$defaultValue'); */ echo  form_dropdown('state', \$choices_states, \$row->state); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
            }
            elseif (($t == "dropdown") && ($fn != "state"))
            {
                $code .= <<<EOD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo \$this->validation->error('$fn'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$choices_{$fn}s = array('' => 'Select one:', 'Choice1'=>"Value1", 'Choice2'=>"Value2");    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo form_dropdown('{$fn}', \$choices_{$fn}s, (\$this->input->post('$fn')) ? (\$this->input->post('$fn')) : '\$defaultValue'); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>\n\n
EOD;
            }    
        $i++;
        }

        $code .= <<<EOD

&nbsp;&nbsp;&nbsp;&nbsp;<tr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top">&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td valign="top"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input name="submit" type="submit" id="submit" value="Submit" style="font-family:Verdana; font-size:8pt; font-weight:bold; color:#FFFFFF; height:20; background:#000066; border:1 solid #808080; cursor:hand"&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
&nbsp;&nbsp;&nbsp;&nbsp;</tr>

&lt;/form&gt;
</table>
&lt;/textarea&gt;

<br /><br />
<strong>View:</strong> $view_delete_file_name<br /><br />
&lt;textarea name="code" rows="5" cols="100" id="myCpWindow5" class="codepress php linenumbers-on"&gt;
<br />
&lt;?php echo anchor('$lc_controller_name/$view_delete_base/'. \$this->uri->segment(3), 'Yes, remove $lc_controller_name', array('class' => 'dbplink')); ?&gt; | &lt;?php echo anchor('$lc_controller_name/view', 'Cancel', array('class' => 'dbplink')); ?&gt;
&lt;/textarea&gt;

&lt;/form&gt;</table>
<br /><br />
EOD;
                
        return $code;    
    }
    
}

?&gt;

application/controllers/crud.php


&lt;?php

class Crud extends MY_Controller {
    
    function __construct()
    {
        parent::MY_Controller();
        $this->load->library('session');
        $this->load->library('CRUD_Buster');
        //$this->output->enable_profiler(TRUE);
    }

    function index()
    {
        if ( !$this->session->userdata('usertype') == "Admin" )
        {
            redirect('home', 'location');
        }
        else
        {
            $rules = array(
                'data_type' => "trim|required|xss_clean",
                   'field_list' => "trim|required|xss_clean",
                   'description_list' => "trim|required|xss_clean",
                   'database_table' => "trim|required|xss_clean",
                   'dbfield_type' => "trim|required|xss_clean",
                   'field_type' => "trim|required|xss_clean"
                   );  
        
            $fields = array(
                'data_type' => "Data Type",
                'field_list' => "List of Fields",
                'description_list' => "Description List",
                'database_table' => "Database Table",
                'dbfield_type' => "Database Field Type",
                'field_type' => "Field Type"
                );
    
            $this->validation->set_rules($rules);
            $this->validation->set_fields($fields);
            $this->validation->set_error_delimiters('<div class="error">', '</div>');
            
            if ($this->validation->run() == FALSE)
            {                        
                $data['head_title'] = 'Create Code';
                $this->template->load('mainTemplate', 'crud_buster/code_create', $data);
            }
            else
            {
                $data['code'] = $this->crud_buster->output_controller_code();
                $data['javascript'] = ('');
                
                $data['head_title'] = 'View Code';
                $this->template->load('mainTemplate', 'crud_buster/code_view', $data);
            }
        }            
    }

}
?&gt;

views/crud_buster/code_create.php


<h1>Create a form</h1>

<table>

&lt;?php echo form_open('code_generator/index'); ?&gt;

&lt;?php echo form_hidden('added_by', $this->session->userdata('user_id')); ?&gt;
&lt;?php echo form_hidden('added_on', date('Y-m-d h:i:s')); ?&gt;

    <tr>
        <td valign="top"><span class="FormFieldTitle">Type of data this form will handle<br />(singular -- do not add an "S" at the end!):<br />Example: user</span></td>
        <td valign="top">
            &lt;?php echo $this->validation->error('data_type'); ?&gt;
            &lt;input type="text" name="data_type" value="&lt;?php echo $this-&gt;validation->value('data_type'); ?&gt;" size="25" />
        </td>
    </tr>

    <tr>
        <td valign="top"><span class="FormFieldTitle">Field List (separate by |):<br />Example: first_name|last_name|address1</span></td>
        <td valign="top">
            &lt;?php echo $this->validation->error('field_list'); ?&gt;
            &lt;textarea name="field_list" rows="4" cols="70"&gt;&lt;?php echo $this->validation->value('field_list'); ?&gt;&lt;/textarea&gt;
        </td>
    </tr>    
    
    <tr>
        <td valign="top"><span class="FormFieldTitle">Field Descriptions (separate by |):<br />Example: First Name|Last Name|Street Address</span></td>
        <td valign="top">
            &lt;?php echo $this->validation->error('description_list'); ?&gt;
            &lt;textarea name="description_list" rows="4" cols="70"&gt;&lt;?php echo $this->validation->value('description_list'); ?&gt;&lt;/textarea&gt;
        </td>
    </tr>
    
    <tr>
        <td valign="top"><span class="FormFieldTitle">Database Table:</span></td>
        <td valign="top">
            &lt;?php echo $this->validation->error('database_table'); ?&gt;
            &lt;textarea name="database_table" rows="4" cols="70"&gt;&lt;?php echo $this->validation->value('database_table'); ?&gt;&lt;/textarea&gt;
        </td>
    </tr>    
    
    <tr>
        <td valign="top"><span class="FormFieldTitle">Database Field Types (separate by |):<br />Example: first_name VARCHAR(200) NULL PRIMARY KEY auto_increment|last_name VARCHAR(150) NULL|address1 VARCHAR (150) NULL</span></td>
        <td valign="top">
            &lt;?php echo $this->validation->error('dbfield_type'); ?&gt;
            &lt;textarea name="dbfield_type" rows="4" cols="70"&gt;&lt;?php echo $this->validation->value('dbfield_type'); ?&gt;&lt;/textarea&gt;
        </td>
    </tr>     
    
    <tr>
        <td valign="top"><span class="FormFieldTitle">Form Field Types (separate by |):<br />Valid types: input|textarea|dropdown|checkbox|radio</span></td>
        <td valign="top">
            &lt;?php echo $this->validation->error('field_type'); ?&gt;
            &lt;textarea name="field_type" rows="4" cols="70"&gt;&lt;?php echo $this->validation->value('field_type'); ?&gt;&lt;/textarea&gt;
        </td>
    </tr>                          

    <tr>
        <td valign="top">&nbsp;</td>
        <td valign="top"><br>

            &lt;input name="submit" type="submit" id="submit" value="Create Code" style="font-family:Verdana; font-size:8pt; font-weight:bold; color:#FFFFFF; height:20; background:#000066;
        border:1 solid #808080; cursor:hand"&gt;

        </td>
    </tr>
    
&lt;/form&gt;
</table>

views/crud_buster/code_view.php


&lt;?php echo $code; ?&gt;