Jump to content

Database Search


phpretard

Recommended Posts

Make a connection to the db, and select the db that you want to work with... then

 

 

<?php
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_object($result))
{
$tables[] = $row->Tables_in_DBNAME;
};
print_r($tables);
?>

 

There is your list of tables in an array.... note DBNAME.... you will have to include the name of the database that your accessing.... It apparently will not allow you to do an      AS XXX clause with this...

 

So once you have your table array, then you can either loop through it and run the query against 1 table at a time or you can implode them and return the string you need...

 

$newString = implode(", ", $tables);

 

This will create a string out of the array and separate the pieces with a comma which you can most likely just plug the variable into your query to get the result you want.

 

Hope this gets you started in the right direction.

 

Nate

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/114484-database-search/#findComment-588820
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.