English 中文(简体)
外籍人搜查假肢
原标题:Codeigniter Search Pagination

我在一些搜索引擎上工作,我想有冰层,但看上去看不上《持久性有机污染物》。 我以某种形式进入了搜索查询程序,在形式之后,取得了一些成果。 第一个成果页通常是和工作,但如果我点击我想象中的其他任何一页,则没有结果,因为名册上的投入价值没有储存的地方。 我已经试图与GET一样进行搜捕,在URL中添加询问,但这也是不可能做到的,因为《国际识别剂》允许某些带有透镜的特性。 我也想把第64基地的争.同起来,但是,这也看不到这一点,因为有些不确定的特征再次出现。

我必须做些什么来取代所有这些?

最佳回答

您可将POST数据转换成GET数据(例如,作为URL参数,见Query part,以及

问题回答
Search with Pagination in Codeingter

Step 1 : Created search_results.php in view
  <?php include ( public_header.php );?>
  <div class="container">
   <h1>Serach Results</h1>
   <table class="table">
    <thead>
     <tr>
      <td>Sr No.</td>
      <td>Article Title</td>
      <td>Published On</td>
     </tr>
    </thead>
    <tbody>
     <tr>
    <?php if(count($articles)):?>
     <?php $count=$this->uri->segment(4,0);?>
     <?php foreach($articles as $article ):?>
      <td><?= ++$count?></td>
      <td><?= $article->title?></td>
      <td><?= "Date" ?></td>
     </tr>
     <?php endforeach;?>

    <?php else: ?>
     <tr>
      <td colspan="3"> No Records Found.</td>
     </tr>
     <?php endif;?>
    </tbody>
   </table>
   <?= $this->pagination->create_links();?>
  </div>

  <?php include ( public_footer.php );?>

step 2 created function in controller

  public function search()
  {
   $this->load->library( form_validation );
   $this->form_validation->set_rules( query , Query , required );

   if(! $this->form_validation->run())
    $this->index();

   $query=$this->input->post( query );
   return redirect("user/search_results/$query");

   // $this->load->view( public/search_results ,compact( articles ));
  }

  public function search_results($query)
  {
   $this->load->helper( form );
   $this->load->model( articlesmodel , articles );
   $this->load->library( pagination );
   $config=[
      base_url   => base_url("user/search_results/$query"),
      per_page    => 5,
      total_row   => $this->articles->count_search_results($query),
      full_tag_open  => "<ul class= pagination >",
      full_tag_close => "</ul>",
      first_tag_opne  => "<li>",
      first_tag_close => "</li>",
      uri_segment   => 4,
     //  first_link   => "<li>"
     //  last_link    => "</li>"
      last_tag_opne  => "<li>",
      last_tag_close  => "</li>",
      next_tag_opne  => "<li>",
      next_tag_close  => "</li>",
      pre_tag_open   => "<li>",
      pre_tag_close  => "</li>",
      num_tag_open   =>  <li> ,
      num_tag_close  =>  </li> ,
      cur_tag_open   => "<li class= active ><a>",
      cur_tag_close  =>  </a></li> ,
   ];

   $this->pagination->initialize($config);
   $articles=$this->articles->search($query,$config[ per_page ],$this->uri->segment(4));
   $this->load->view( public/search_results ,compact( articles ));
  }

Step 3 :Created function in model

  public function search($query,$limit,$offset)
  {
   $q=$this->db->from( articles )
      ->like( title ,$query)
      ->limit($limit,$offset)
      ->get();
   return $q->result();
  }
  public function count_search_results($query)
  {
   $q=$this->db->from( articles )
     ->like( title ,$query)
     ->get();
   return $q->num_rows();
  }




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签