#!/usr/bin/php query("SHOW tables FROM $database;"); //print_r($db1->result); while( $table = $db1->result->fetch_assoc()) { echo "======================>" . $table['Tables_in_nextcloud']; $db2->query("SHOW columns FROM " . $table['Tables_in_nextcloud']); $columns = $db2->result->fetch_all(); foreach($columns AS $key=>$s) { if (array_search($string, $columns) !== false) { echo "column " . $s . " => " . "$key"; } } } ?>