Welcome Guest, Not a member yet? Register   Sign In
add extra rows in a HTML table

Hi People,

can anyone tell me if it's possible to add a extra collum when I use

when I do this:

$sql = 'SELECT * FROM mytable'

it shows a perfect table
but I want a extra collumn so I can add some buttons delete and update

anny idea's of can annyone show me a basic example for this?



Maybe with .after()?

ok jquery solution
but is there a php or codeignitor solution?

Do you have code for delete and update? Have you done with that part already?
That are no CI or PHP solution in general. You need sql solution here. There are two approaches:

1.) statically generated table output (which you have now) as is

That means you need all data predefined in table column already so in that column cell there could be something like
http://example.com/edit/1 (1 == id of row) for example.

2.) dynamically adding cell on generated table in which (cell) you will put value shown few lines above

This second approach is more flexible because you can combine different controllers with no changing DB, if needed.
In DB you already have data you need, and it is row_id. How shell output be generated is less important IMHO.


hi Tpojka

I will figure out how to make the delete and upgrade script

but to add a collumn isn't that posible to do wth $this->table->make_columns()
like the manual explains?


can I somehow combine that with

It is something you would need do just once.
Just use sql alter table for that.
I am saing again, you will need to know predefined data that should be stored in that column.
I assume it is something like uri string. If this is your approach to task, figure out what will be representing of mentioned URLs for update and delete (if no any other functions) regarding of routes.php, .htaccess files.
If you know exact match of those methods and URLs respectivelly, make an controller that will insert column data for every row.
How many records (rows) are there so far?

If I had that task, I would still vote for jquery populating table.

not sure if we are on the same page here :-) my question is how to add a extra collumn to a HTML table
not a SQL table, are we talking about the same thing here?


I am talking about your problem, but don't know what do you talking about. Big Grin

HTML table is table you are getting from your DB.table columns. Is that ok?
So, if you want representation of one more column, you need to have it in DB.table as well so it could be presented such the rest columns from DB. What is not clear with that to you?
Can you post code you have already?

ok this is what I have:
the names are in dutch

public function overzicht() {
        $data['title']          = 'overzicht';
        $data['main_content']   = 'overzicht';
        $data['gen_query']      = $this->Get_DB->overzicht();
        $this->load->view("template", $data);

the model part:

public function overzicht() {
        $query = $this->db->query("SELECT * FROM invoer "
        . "ORDER BY datum DESC");
        $gen_query = $this->table->generate($query); // <<< results are just perfect, shows all I need
        return $gen_query;

the view part:
echo anchor('brandstof/insert','Toevoegen','class="button"'); //go to the view that inserts data
echo $gen_query;

but now I want to add a extra table header with title "operations"
and after each table row I want a anchor "edit" and "delete"

kan I manage that with the
$gen_query = $this->table->generate($query);
method of do I need to create a HTML table manualy?


I know for two methods described already.
It is perfect example for using jquery.
I suggest you that read documentation and examples that could be solution.
Or wait to see if someone else knows some other way, maybe.
Or check some other examples before that.

Theme © iAndrew 2016 - Forum software by © MyBB