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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:44:34+00:00 2026-05-26T05:44:34+00:00

I’m trying to display two columns in my table view, one being a title

  • 0

I’m trying to display two columns in my table view, one being a title of the document, the next being a description of the document. I have a column in the particular table which I am selecting named “filename” that stores the name of the uploaded document which is associated with it’s title and description.

I’m curious as to how I would manage to display only the title and description, while setting the data contained in the “filename” column as the hyperlink value of the title? (Basically, I’m wanting them to be able to download a document once they click on it’s name)

I’m fairly certain that I can pull this off by manually by skipping the table generator and doing a “foreach” in the view to print out all the data from the resultset, but I’m open to suggestions, as this would make for sloppy code. Here’s a snippet of my controller below.

<?php
class blah extends CI_Controller { 
    public function troubleshooting() {
        $this->load->library('pagination');
        $this->load->library('table');

        $config['base_url'] = 'http://somewebsite.com/troubleshooting';
        $config['total_rows'] = $this->db->get('document')->num_rows();
        $config['per_page'] = 10;
        $config['num_links'] = 10;
        $this->pagination->initialize($config);
        $data['records'] = $this->db->get('document', $config['per_page'],$this->uri->segment(3));
        $this->db->select('doc_title, filename, description, category_id, product_id');
        $this->db->where('category_id = 1'); 
        $this->db->where('product_id = 1'); 
        $this->db->order_by('doc_title', 'asc');
        $this->load->view('blah/troubleshooting.php', $data);
    }
} 
  • 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-26T05:44:34+00:00Added an answer on May 26, 2026 at 5:44 am

    You can create the link in your query with a select->(CONCAT(...), FALSE) query.

    http://codeigniter.com/forums/viewthread/105687/#531878

    ** UPDATE **
    Well, your table helper is going to receive an array – and your db query is going to return an array. So, you have to create your query in a way that will create your array the way you need it for the table helper.

    You need something like this:

    $records = [
        'doc_title' => 'My Title',
        'filename' => '<a href="path/to/filename.php">filename.php</a>',
        'description' => 'My description text here.',
        'category_id' => 5,
        'product_id' => 56
    ]
    

    Your query might look like this:

    $this->db->select('doc_title');
    $this->db->select('CONCAT("<a href=path/to/'.filename.'>".'filename'."</a>")', FALSE);
    $this->db->select('description, category_id, product_id');
    $this->db->where('category_id = 1'); 
    $this->db->where('product_id = 1'); 
    $this->db->order_by('doc_title', 'asc');
    
    $records = $this->db->get('document', $config['per_page'],$this->uri->segment(3));
    

    The trick is your CONCAT function will have some ‘quote’ issues. Without actually testing this myself, I’m not sure I’ve got the quotes right. Take a look at some docs there and that should help: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display my data (images) in two columns of a table
I'm trying to display two columns in a datatable(dt) into a datagrid. And add
I'm trying to display a page in NSIS to obtain two different values. I
I have two tables, one is signups and contained in it are two fields,
I am trying display values in a datagrid in my application. I have all
I am trying to use two different string functions (initcap and trim) on one
I have a table that has a column that contains links. Each cell in
I am trying to display all of the products showing the dates they have
I'm trying to design a page that has two columns of content, div#left and
I'm trying to display three columns in a DataGridView. Here is a sample of

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.