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

[eluser]raffie77[/eluser]
Hi People,

can anyone tell me if it's possible to add a extra collum when I use
$this->table->generate($sql)

when I do this:

Code:
$sql = 'SELECT * FROM mytable'
$this->table->generate($sql)

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?

regards,

Ralph
#2

[eluser]Tpojka[/eluser]
Maybe with .after()?
#3

[eluser]raffie77[/eluser]
ok jquery solution
but is there a php or codeignitor solution?
#4

[eluser]Tpojka[/eluser]
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.

#5

[eluser]raffie77[/eluser]
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?

http://ellislab.com/codeigniter/user-gui...table.html

can I somehow combine that with
Code:
$this->table->make_columns()
#6

[eluser]Tpojka[/eluser]
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.
#7

[eluser]raffie77[/eluser]
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?

Ralph
#8

[eluser]Tpojka[/eluser]
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?
#9

[eluser]raffie77[/eluser]
ok this is what I have:
the names are in dutch

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

the model part:

Code:
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:
Code:
&lt;?php
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
Code:
$gen_query = $this->table->generate($query);
method of do I need to create a HTML table manualy?

Ralph
#10

[eluser]Tpojka[/eluser]
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