Fill A Select type with an other SQL
Fill A Select type with an other SQL
lifedaniel
Posts: 68Questions: 4Answers: 0
Hello I would like to know how to fill
editor.field('ctva').update( [
'0%', '6%', '21%'
] );
With an other SQL table. Giving names, and value.
Or can I put PHP code on .js file ??
lifedaniel
This discussion has been closed.
Replies
You can have PHP output Javascript if you want (I do it on this site). Or you can load the data like in this example: https://editor.datatables.net/examples/simple/join.html
I already tried to use this example, but it uses a JOIN. Wich in not my case.
My php is like this :
How can I use an other table with this ?
The fact that the example uses a join shouldn't really make any difference. Have a look at line 30 in the PHP of the example I linked to:
That's how it gets the data for the example's select list.
Allan
the first "sites" and second one correspond to what? db name? table? user ?
no error and loading but the select is EMPTY..
up to not lose the post
My example above uses the
selectDistinct
method documented here: http://editor.datatables.net/docs/Editor-1.3.2/php/class-DataTables.Database.html#_selectDistinct . So its arguments are the table and then the field.Did you use
initComplete
as shown in the example I linked to before to populate the select based on yourdatatabletest
data?Allan
Yeah but json.sites correspond to what? Can't find it
and selectDistinct( $table, $field = "*", $where = null, $orderBy = null )
doesn't look like ->selectDistinct( 'sites', 'id as value, name as label' )
dunno how to apply it
I think my problem come from
initComplete: function ( settings, json ) {
// Populate the site select list with the data available in the
// database on load
editor.field( 'ctva' ).update( json.ctva );
}
dunno what to put in update();
OK said nothing everything working now thank you