how to insert a non-database field?

how to insert a non-database field?

wznjsywznjsy Posts: 2Questions: 0Answers: 0
edited September 2010 in General
Hi All,
I am totally new to PHP, and want to insert 2 non-database field to datatable.

My current config for columns is

$aColumns = array('id','title ','time_created','time_updated');

I want to my datatables to show 2 extra fields, one is to insert some picture, and the other is used to insert some link.


P.S.: I want it could be searched like other columns.


I want to do it in my php ajax source

I know there is comment like "Use a space where you want to insert a non-database field (for example a counter or static image)", but it did not work me.

What have a tried:
$aColumns = array('id','title ','time_created','time_updated', );
$aColumns = array('id','title ','time_created','time_updated',' ' );


How should I modify the $aColumns and output codes? Can someone help me?

Thank you very much.

Replies

  • rewenrewen Posts: 74Questions: 2Answers: 0
    edited September 2010
    If you are using the example server-side php code, just add another sOutput line and make sure the content is escaped properly (use the addslashes function or do it yourself):
    [code]$sOutput .= '"",';[/code]
    Be sure to remove the comma if it's the last sOutput line (aka the last column)

    Another server-side script (a modification of the example one) can be found here, where you can just add something like this:
    [code]$row[] = "";
    $row[] = "Link";[/code]
    Script: http://datatables.net/forums/comments.php?DiscussionID=2651&page=1
  • sd_zuosd_zuo Posts: 78Questions: 1Answers: 0
    Hello,

    I think a better idea for you is to dynamically insert/append the non-database things on the client side.
    Given that the AJAX source array is d, and you want an extra column inserted at the first column, you can call the following code before drawing the table.
    [code]
    $.each(d, function(i, n) { n.unshift(0); });
    [/code]
  • lukyluky Posts: 4Questions: 0Answers: 0
    edited February 2012
    hi i have server-side script from http://www.datatables.net/development/server-side/php_mysql

    at the end its
    [code]
    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
    $row = array();
    for ( $i=0 ; $i
    [/code]

    how i can add non-database fields ?:p Thank you
This discussion has been closed.