Hi. I'm not sure if this is possible or not, but I need to be able to SELECT * FROM all the tables in the database. Is this possible?


Recommended Answers

All 2 Replies

I would use following steps:
1. Put Tables in array

mysql_connect($server, $login, $password);
$res = mysql_query("SHOW TABLES FROM $db");
$tables = array();
while($row = mysql_fetch_array($res, MYSQL_NUM)) {
    $tables[] = "$row[0]";

2. Loop the array and query each table.
Now it is up to you to test my "workable" theory!
Also for (1) you can use mysql_list_table

Yes it is possible. You retrieve all the tables in the database with mysql_list_tables($database)function where $database is the variable holing the database name.You then retrieve the actual table names with mysql_tablename() function and store them in an array. You then put the Select * from array name in a loop. For example-

		$qy2=mysql_query("SELECT  * FROM"." ".$table_directory[$k]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.