Tanmay Maity


Leave a comment

Get WordPress Table’s column name

For any reason if you need the MySQL table’s columns name in WordPress then use below code.

global $wpdb;
$table = $wpdb->prefix . 'table_name';
$column = $wpdb->get_col( "DESC " . $table, 0 );

Now you have the all columns of the table $column array. Print those

foreach( $column as $key => $value ) {
echo $value;
}


Leave a comment

Fix: Force downloaded Zip file corrupted/invalid

If you are working on creating zip file and force download the created Zip file, then some time you will face an issue that the downloaded Zip file is corrupted, in Safari the auto decompression will also fail.
To solve above problem after set the header and before downloading the file use “ob_clean” and “flush” to clear the buffer.