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 6922501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:24:51+00:00 2026-05-27T10:24:51+00:00

I have pages of data, pulled from a database. I need to be able

  • 0

I have pages of data, pulled from a database. I need to be able to delete a record on the page which is displaying all of the rows of data.

So customers/index displays all of the rows. Controller:

public function index($page = 'customer_list', $title = 'Customer List') {      
    $this->exists($page);

    $data['customer'] = $this->customers_model->get_customers();
    $data['title'] = $title;
    $data['content'] = 'content/'.$page.'.php';

    $this->load->view('frame/grab', $data);
}

public function delete() {  
    $this->customers_model->delete_customer();

    $this->index();
}

It uses this model function:

public function get_customers() {
    $this->load->library('pagination');

    //Config for pagination
    $config['base_url'] = '**cant post links**/customers/index';
    $config['total_rows'] = $this->db->get('customers')->num_rows();
    //Rows per page
    $config['per_page'] = 10;
    //Number of links shown to navigate
    $config['num_links'] = 20;

    //Initializes the pagination
    $this->pagination->initialize($config);

    $query = $this->db->get('customers', $config['per_page'], $this->uri->segment(3));
    return $query->result();
}

Here is my view:

    <div class="main-content">
        <div class="main-content-header">
            <h2 class="floatl"><?php echo $title; ?></h2>
            <a class="add-new floatr" href="<?php echo base_url(); ?>customers/add"><h4>Add New Customer &raquo;</h4></a>

            <div class="clear"></div>
        </div>

        <div class="sort-container">
            Sort by:
            <ul class="sort">
                <li><a href="#">ID Ascending</a></li>
                <li><a href="#">ID Descending</a></li>
                <li><a href="#">First Name</a></li>
                <li><a href="#">Last Name</a></li>
            </ul>
        </div>

        <?php
        //Creates the template for which the table is built to match
        $tmpl = array ( 'table_open'          => '<table class="data-table">
                                                    <tr class=\'tr-bgcolor table-header\'>
                                                        <td>#</td>
                                                        <td>First Name</td>
                                                        <td>Last Name</td>
                                                        <td>Edit</td>
                                                        <td>Delete</td>
                                                    </tr>',

                        'heading_row_start'   => '<tr>',
                        'heading_row_end'     => '</tr>',
                        'heading_cell_start'  => '<th>',
                        'heading_cell_end'    => '</th>',

                        'row_start'           => '<tr class="tr-bgcolor">',
                        'row_end'             => '</tr>',
                        'cell_start'          => '<td>',
                        'cell_end'            => '</td>',

                        'row_alt_start'       => '<tr>',
                        'row_alt_end'         => '</tr>',
                        'cell_alt_start'      => '<td>',
                        'cell_alt_end'        => '</td>',

                        'table_close'         => '</table>'
                      );

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

        //Creates table rows from the rows of data in the db which were created as the customer array
        foreach ($customer as $row) :
            $this->table->add_row(
                $number = array('data' => $row->rec_num, 'class' => 'center'),
                $row->last_name,
                $row->first_name,
                $edit = array('data' => '[ <a href="#">Edit</a> ]'),
                $edit = array('data' => '[ <a href="'.base_url().'customers/delete/'.$row->rec_num.'">Delete</a> ]')
            );
        endforeach;

        //Creates the table based on the rows determined above
        echo $this->table->generate();

        //Creates page links
         echo $this->pagination->create_links();
        ?>
    </div>

So I’m thinking that the pagination is getting in the way, because when I click the delete link, it sends it to customers/delete/#. So it deletes the record, as it should, but the displayed results are varied because I believe the pagination is off setting the displayed rows by the number in the URL (Which is actually just the ID of the row).

Any help is greatly appreciated.

  • 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-05-27T10:24:52+00:00Added an answer on May 27, 2026 at 10:24 am

    I think that the best way is make redirect after deleting row in db to the index page:

    public function delete() {  
        $this->customers_model->delete_customer();
        redirect('customers/index');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP page with a list of items pulled from a database.
I have a PHP page and I want to share some data between pages
I have a page that needs to combine data from four different webrequests into
I am trying to get data pulled from a SQLite file, i have created
I have a page where values from a table in my database are being
I used to have a python script that pulled data from the below table
I do have 8 tables. when a query fires from search page data from
What is the quickest way to put up a mobile-friendly page displaying data pulled
Short question: I need to turn a dynamic image pulled from a database into
I have a form on one page, some of the form data is pulled

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.