Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8083577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:31:06+00:00 2026-06-05T17:31:06+00:00

I am trying to create dynamic pages without creating new files and getting the

  • 0

I am trying to create dynamic pages without creating new files and getting the data from the database…

so my table will be like:

Pages
------
id | page_name | text
1  | about     | about page goes here
2  | contact   | contact page goes here

now my question is how can i manage to make $this->uri->segement(1) to automatically check if the given page name exist in database?

do i have to create a new controller that will handle all this or?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:31:07+00:00Added an answer on June 5, 2026 at 5:31 pm

    If you have several pages that you want to check, I would recommend having a Pages controller that managers those pages. Something like this

    class Pages extends CI_Controller {
        public function view($page_name)
        {
            $this->load->Pages_model();
    
            if($this->Pages_model->does_exist($page_name))
            {
                // Does exist. Do things.
            } else
            {
                show_404();
            }
        }
    }
    

    In your routes.php, you route your about and contact pages (and whatever others you may have) to the pages controller.

    $route['about'] = "pages/view/about";
    $route['contact'] = "pages/view/contact";
    

    Your Pages_model will need a simple function that checks if the page name exists in the database.

    function does_exist($page_name) {
    
        $this->db->where('name', $page_name); // assuming you have a table with a `name` field
        $query = $this->db->get('pages'); // select from the `pages` table
        return $query->num_rows() > 0; // returns bool
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create dynamic menus from the database using the following example
i'm trying to create a Dynamic Sub-menu to use it in Wordpress, Something like
I'm trying to create a dynamic datagrid in Flex. The data is coming back
I am trying to make dynamic function where user can create list without adding
For a project, I'm having dynamic pages that are retrieved from a content database.
I am trying to create a conditional statement on my dynamic product pages on
I am trying to get data from database for Google charts in my program.
I am trying to create a dynamic 'page' listing for threads/comments using AJAX. in
I'm trying to create a dynamic point system based off of how much money
I'm trying to create a dynamic regex to select URL's based on a segment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.