All pastes #565198 Raw Edit

Something

public php v1 · immutable
·published 2007-06-13 22:27 UTC
rendered paste body
$sql = "SELECT DISTINCT term FROM logs WHERE term_soundex LIKE LEFT(SOUNDEX('$trimmed'),4) AND results2 >0 AND term REGEXP '[0-9]' !=1 LIMIT 10"; 	$result = mysql_query($sql) or die ("<center> ERROR: ".mysql_error()."</center>");	          $x = 0;	          echo "<table border=\"1\" align=\"center\">";     	          while($row = mysql_fetch_array($result, MYSQL_NUM))	        {								$compare = $row[term];						$levenshtein = levenshtein($trimmed, $compare);						$lengthdifference = max($trimmed, $compare) - min($trimmed, $compare);						$levenshtein-=$lengthdifference;						$similarity = $levenshtein/strlen(min($trimmed, $compare));				$row[] = $similarity;					sort($row, SORT_DESC);	            if ($x == 0) // so that table headers are only created on the first pass	            {			                $col = (count($row)); // counts number of elements in the array	                  $x=1;	                echo "<tr>";	                for ($y=0; $y<$col; $y++)	                {	                    echo "<th>";	                    echo key($row); // gets the names of the fields	                    echo "</th>";	                    next($row);	                }	                echo "</tr>";	            }	            reset($row);	            echo "<tr>";	            for ($y=0; $y<$col; $y++)	            {	                echo "<td valign=\"top\" align=\"left\">";	                echo current($row);	                echo"</td>";	                next($row);	            }	            echo "</tr>";			        }  // end of while loop