방랑로그

[php] codeigniter php framework 본문

IT개발/PHP

[php] codeigniter php framework

야키다 2017. 12. 15. 18:31

[php] codeigniter php framework 



http://codeigniter.com/


한국어 메뉴얼

http://codeigniter-kr.org/user_guide/general/styleguide.html


=============

* 컨트롤 만들기

* table


<?php

class b extends Controller {

 function index()

 {

  $this->load->library('table');

 

  $tmpl = array (

      'table_open'          => '<table border="5" width=100% cellpadding="4" cellspacing="0">',

      'heading_row_start'   => '<tr>',

      'heading_row_end'     => '</tr>',

      'heading_cell_start'  => '<th>',

      'heading_cell_end'    => '</th>',

      'row_start'           => '<tr  bgcolor=gray>',

      'row_end'             => '</tr>',

      'cell_start'          => '<td align=center>',

      'cell_end'            => '</td>',

      'row_alt_start'       => '<tr  bgcolor=lightgrey>',

      'row_alt_end'         => '</tr>',

      'cell_alt_start'      => '<td>',

      'cell_alt_end'        => '</td>',

      'table_close'         => '</table>'

      );

  $this->table->set_template($tmpl);

  $data = array(


     array('Mary', 'Red', 'Large'),     array('Fred', 'Blue', 'Small'),

     array('Mary', 'Red', 'Large'),     array('Fred', 'Blue', 'Small'),

     array('Mary', 'Red', 'Large'),     array('Fred', 'Blue', 'Small'),

     array('Mary', 'Red', 'Large'),

     array('John', 'Green', 'Medium')

     );

   echo $this->table->generate($data);

 

  $this->bview() ;

 }

 function bview()

 {

  $this->load->view('v/bview'); 

 }

}

?>





<hr>

<?

$this->table->set_empty("&nbsp;--");

$this->table->clear() ;

$data = array(

   array('오리', '너구리', '그리고'),

   array('John', 'Green','')

   );

 echo $this->table->generate($data);

$list = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve');

$new_list = $this->table->make_columns($list, 3);

$this->table->set_heading(array('Name', 'Color', 'Size','123'));

echo $this->table->generate($new_list);


?><hr>





* 폼검증


<html>

<head>

<title>My Form</title>

</head>

<body>

<?php echo validation_errors(); ?>

<?php echo form_open('c');

echo $_POST['username'] ;

?>

<h5>Username</h5>

<input type="text" name="username" value="<?=$_POST['username']?>" size="50" />

<h5>Password</h5>

<input type="text" name="password" value="" size="50" />

<h5>Password Confirm</h5>

<input type="text" name="passconf" value="" size="50" />

<h5>Email Address</h5>

<input type="text" name="email" value="" size="50" />

<div><input type="submit" value="Submit" /></div>

</form>

</body>

</html>



<?php

class c extends Controller {

 function index()

 {

  $this->load->helper(array('form', 'url'));

 

  $this->load->library('form_validation');

 

  $this->formcheckinit() ;

  

  if ($this->form_validation->run() == FALSE)

  {

   $this->load->view('v/cview') ;

  }

  else

  {

   $this->load->view('v/cview2') ;

  }


 

 }

 function formcheckinit()

 {

 

 $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');

$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');

$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');

$this->form_validation->set_rules('email', 'Email', 'required|valid_email');


 }


 function cview()

 {

  $this->load->view('v/cview') ;

 

 

 

 

 }


}

?>



Comments