petecorbs Posted August 11, 2007 Share Posted August 11, 2007 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 More sharing options...
calabiyau Posted August 11, 2007 Share Posted August 11, 2007 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 Link to comment https://forums.phpfreaks.com/topic/64436-searching-my-entire-database/#findComment-321281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.