note 63917 deleted from function.mysql-list-tables by danbrown

From: Date: Tue, 12 Jul 2011 19:05:13 +0000
Subject: note 63917 deleted from function.mysql-list-tables by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181441@lists.php.net to get a copy of this message
Note Submitter: arturclemente at gmail dot com ---- <?php // Search any world in entire database set_time_limit(0); $database = 'embratur'; $word = 'tempo'; echo "Search for word: <b>".$word."</b><br><br>"; $connect = mysql_connect('localhost','root','123456'); mysql_selectdb( $database, $connect ); $j=0; $tables = mysql_list_tables( $database ); while( $line = mysql_fetch_row( $tables ) ) { $fields = mysql_list_fields( $database, $line[0], $connect ); $columns = mysql_num_fields( $fields ); for ($i = 0; $i < $columns; $i++) { $nomField = mysql_field_name( $fields, $i ); $sql = "SELECT ".$nomField." FROM " . $line[0] . " WHERE " . $nomField . " LIKE '%".$word."' LIMIT 1"; $query = mysql_query( $sql ); if( mysql_num_rows( $query ) > 0) { $result = mysql_fetch_array( $query ); echo "Table: <b>".$line[0]."</b><br>"; echo "Field: <b>".$nomField."</b><br>"; echo "SQL: <b>".$sql."</b><br>"; echo "Result: <b>" . str_replace( $word, "<font color='blue'>". $word . "</font>", $result[0] ) . "</b>"; echo "<br><br>"; $j++; } } } echo "<br><br><br>"; echo "Results: ".$j; ?>

« previous php.notes (#181441) next »