小编har*_*ham的帖子

如何在Codeigniter分页中使用页码而不是偏移量?

我已经阅读了有关Stackoverflow的所有问题,并且没有看到问题的确切答案.我目前正在使用codeigniter分页库来使用限制和偏移量生成我的分页链接:

$config['base_url'] = base_url() . 'explore/featured/index/';
    $config['total_rows'] = $this->Projects_model->get_featured_count();//Count featured projects
    $config['per_page'] = 12;
    $config['uri_segment'] = 4;
    $config['display_pages'] = FALSE;
    $config['next_link'] = 'Older →';
    $config['prev_link'] = '← Newer';
    $this->pagination->initialize($config);
    $limit = $config['per_page'];
    $offset = $this->uri->segment(4);

    $data['pagination'] = $this->pagination->create_links();

    $data['projects'] = $this->Projects_model->get_featured($limit, $offset); //get featured projects from database
Run Code Online (Sandbox Code Playgroud)

上面的代码限制了我的查询的输出值,并使用了我的第4个URI段中包含的偏移量.

如何将以下代码更改为页码??? 似乎是不可能的,因为我将不再能够在我的网址中使用偏移量.

php mysql pagination codeigniter

5
推荐指数
2
解决办法
2万
查看次数

如何在PHP中向数字添加前导零和逗号

我有一个变量$counter,返回以下整数:

4
Run Code Online (Sandbox Code Playgroud)

我想使用数字格式或类似格式使我的整数以这种格式显示:

000,000,004
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

php format integer number-formatting

3
推荐指数
1
解决办法
1320
查看次数

Codeigniter视图:如何为视图创建子目录?

在codeigniter的我的views文件夹中,我希望为每个类别都有一个子目录.

  • /家
  • /关于我们
  • /服务

并且每个都包含不同的视图.

如何将控制器指向这些目录中的视图以及如何为/目录子目录创建默认路由?

php codeigniter directory-structure templating

2
推荐指数
1
解决办法
1920
查看次数

Codeigniter中的单词限制器,如何在限制后回显单词?

我在文本帮助器中使用codeigniter word_limiter()函数。

$string = "Here is a nice text string consisting of eleven words.";

$string = word_limiter($string, 4);

// Returns: Here is a nice…
Run Code Online (Sandbox Code Playgroud)

以上功能将输出限制为四个字。如何将限制后的单词也存储在变量中以供使用???

php codeigniter

1
推荐指数
1
解决办法
1万
查看次数