繁体   English   中英

如何在codeigniter的URL中传递搜索参数

[英]how to pass search parameters in url of codeigniter

codeigniter ,我使用了get方法来搜索数据列表。

我的配置是

在config.php中

$config['index_page'] = '';

的.htaccess

<IfModule mod_php5.c>
php_value max_execution_time 30000
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

我的搜寻网址

http://localhost/store/customer/index?limit=20&search_name=&search_mobile=&search_due=

结果是

404页面不存在。

如何使它在没有index.php情况下工作

Codeigniter提供干净URLS 。您可以解决以下问题。

Customer.php控制器内部,具有带有参数的函数index

function index($limit="",$search_name="",$search_mobile="",$search_due="")
{
//code
echo $limit;//prints 20
}

然后将参数传递给这样的函数。

http://localhost/store/customer/index/20/search_name/search_mobile/search_due

既然您已删除index.php,请删除/input? 从您的网址中,只需使用:

http://localhost/store/customer?limit=20&search_name=&search_mobile=&search_due=

并执行hamed hossani所说的,并使用$this->input->get()返回数组。 或者分别像$limit = $this->input->get('limit'); ($ limit = 20)

https://www.codeigniter.com/user_guide/libraries/input.html#CI_Input::get

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM