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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.