Add new Table in PHP
-
Good day sir!
i’m trying to dynamically create N numbers of Tables on the render php file, but I got an error … “Catchable fatal error: Argument 2 passed to TablePress_Table_Model::_add_table_options() must be of the type array, null given, called in /home4/ncbcomni/public_html/bicomni/digitech/bolsa/wp-content/plugins/tablepress/models/model-table.php on line 460 and defined in /home4/ncbcomni/public_html/bicomni/digitech/bolsa/wp-content/plugins/tablepress/models/model-table.php on line 992”
I created an array and try to call the ADD function… this is my whole function and filter
add_filter( ‘tablepress_table_render_data’, ‘detalles_cordobas’, 10, 3 );
function detalles_cordobas( $table, $orig_table, $render_options ) {
$table_id = 13; // replace with your table id
$header_row = array( ‘TICKER’, ‘MERCADO’,’MÍNIMO’, ‘PROMEDIO’,’MÁXIMO’); // column names
$header_row_detail = array( ‘INSTRUMENTO’, ‘PLAZO’, ‘MERCADO’,’MÍNIMO’, ‘PROMEDIO’,’MÁXIMO’); // column names
$table_id_cord = 18;
$table_id_details = 19;
$table_cordobas = array();
$table_cord = TablePress::$model_table->load( $table_id_cord );
$table_details = TablePress::$model_table->load( $table_id_details);
if ( $table_id == $table[‘id’] ) {
$data_cord = $table_cord[‘data’];
$data_details = $table_details[‘data’];
$table_cordobas[0] = $header_row;
$i = 1;
foreach($data_cord as $arr)
{
$ind_detail_level = 1;
if (strtoupper($arr[1]) == ‘CORDOBAS’) {
$tab_detail = array();
$tab_detail[0] = $header_row_detail;
//Runs to create the details arrays
foreach ($data_details as $arr_detail) {
//Solo los cordobas
if ($arr_detail[0]==’01’) {
//Solo los que pertenecen al TICKER ACTUAL
if ($arr_detail[1] == $arr[2]) {
$detail_level = array();
$detail_level[0] = $arr_detail[2];
$detail_level[1] = $arr_detail[3];
$detail_level[2] = $arr_detail[4];
$detail_level[3] = $arr_detail[5];
$detail_level[4] = $arr_detail[6];
$detail_level[5] = $arr_detail[7];
$tab_detail[$ind_detail_level] = $detail_level;
$ind_detail_level = $ind_detail_level + 1;
}
}
}
$temp = array();
reset($arr);
if ($ind_detail_level > 1) {
//create the new table
reset($tab_detail);
$table_id_details_add = 0;
$table_id_details_add = TablePress::$model_table->add($tab_detail);
//create the popmake that will contain the table
do_shortcode(‘[popup id=”post-“‘. $table_id_details_add .'” size=”medium” title=”‘. $arr[3] .'”] [table id=”‘.$table_id_details_add.'” /][/popup]’);
$str = ‘“‘.$arr[2].'”“‘;
$temp[0] = $str;
}
else {
$temp[0] = $arr[2];
}
$temp[1] = $arr[4];
$temp[2] = $arr[5];
$temp[3] = $arr[6];
$temp[4] = $arr[7];
$table_cordobas[$i] = $temp;
$i = $i +1;
}
}
$table[‘data’] = $table_cordobas;
}return $table;
}I got data from other tables and I try to rename the column name for each ticker, and add a link for a popmake that will show the detail table…
thanks for any help
Have a nice day
The topic ‘Add new Table in PHP’ is closed to new replies.