how to insert a non-database field?
how to insert a non-database field?
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.
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.
This discussion has been closed.
Replies
[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
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]
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