Jump to content

searching my entire database


petecorbs

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

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.