Are you getting any error messages?
Here is an example for a mysqli query:
$mysqli = new mysqli("localhost", "user", "pass", "db");
$query = "SHOW TABLES FROM primeselectscan";
$result = $mysqli->query($query);
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=FILE-NAME-HERE.txt");
header("Pragma: no-cache");
header("Expires: 0");
while($row = $result->fetch_array()) {
echo "\t<tr><td>".$row['Tables_in_primeselectscan']."</td><td>
";
}
$mysqli->close();
If you are wanting the actual table names within the database then you need to change your query to use 'SHOW TABLES FROM dbName'. See http://dev.mysql.com/doc/refman/5.7/en/show-tables.html for details.
To have it output as an actual download add the following headers before you output anything, I added that to the code section above.