Help please

Help please

ShadowAssassinShadowAssassin Posts: 4Questions: 0Answers: 0
edited April 2011 in General
Hello. I am using Codeigniter, and I need some help with Datatables.

Basically, I am getting the ID from the database, and it's in the datatable.

I have a column for deleting the item (files in this instance).

My code for this is: (I have set $custom)

$edit = '';

I want filename to either by equal to the name of the file (in the filename column) or the ID. (so $filename = 1, 2, 3, 4 etc)

How do I set $filename? I mean, I've tried a for loop, and everything. I've even tried using jQuery, and setting a class for the ID column and using the .click function, but it didn't work.

Any help is greatly greatly appreciated :) Thank you.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    How do you set $custom? I would guess in a similar way. Can't you just put an if () condition in your PHP code? It might be best to ask in a PHP specific forum rather than this DataTables forum if it's a PHP question.

    Allan
  • ShadowAssassinShadowAssassin Posts: 4Questions: 0Answers: 0
    edited April 2011
    Thanks very much for the reply, I appreciate it.

    I need to set $filename.

    Basically, I need to get the ID's and for each ID, make $filename = $ID.

    So, I have the table
    ID: 1
    Column2
    Column3
    Delete (image link)

    ID: 2
    Column2
    Column3
    Delete (image link)

    And so on so fourth, the link of the delete image, needs to be equal to the ID.
  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    How are the columns generated at the moment?

    Allan
  • ShadowAssassinShadowAssassin Posts: 4Questions: 0Answers: 0
    Using a codeigniter plugin.

    (https://github.com/IgnitedDatatables/Ignited-Datatables)
  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    I'm afraid I don't know how that module works, so I doubt I'll be able to help too much without looking into it quite closely. What I don't quite understand is if you have the $custom variable as required for each row - why can't you also get the $filename variable in the same manner?

    Allan
  • ShadowAssassinShadowAssassin Posts: 4Questions: 0Answers: 0
    Because $custom is set via $this->config->item('custom'). Which is: localhost/{name}/styles/{name}

    {name} is just example.

    $filename needs to contain each of the ID's. so foreach($query->result() as $row) {

    $filename = $row->id;

    }

    that works, but only gives me one ID across all tables. (so each delete link has the ID of 1, rather then each one being 1, 2, 3, 4)
This discussion has been closed.