Jump to content

Recommended Posts

I want to perform a search on my entire database (not just one table or column) all tables and all columns that will produce results based on a keyword search [eg if someone types 'anything' into my search field it will search all columns in all tables for that word and produce results on each row that contains it].

Every SELECT * FROM WHERE AS LIKE query i put together doesnt seem to work at all

Any ideas help or tutorials of what i am looking for would be great

Link to comment
https://forums.phpfreaks.com/topic/64436-searching-my-entire-database/
Share on other sites

I think you need

 

$tables = mysql_list_tables($database);
while ($row = mysql_fetch_row($tables))

	{
	$table_list[] = $row[0];
}
for ($i=0; $i < count($table_list); $i++)

	{
	$results = mysql_query('DESCRIBE '.$table_list[$i]);


while($row= mysql_fetch_assoc($results))

			{
$query = "SELECT * FROM ".$table_list[$i]." WHERE ".$row['Field']." LIKE %".$your_seach_term."%";
//execute your query and while looping through results
//echo your results here
}

}

 

I'm sure there is a way to do some kind of fancy join, but this is from a database backup script.  sorry if there are a few minor errors but you could do it this way i think

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.