0

i want to echo one value from mysql column which is 90% similar to php variable. echo only the value that is 90% similar to php value. i think like clause wont help in this case.

  <?php
  $x = $_GET[x];
  $con=mysqli_connect("example.com","peter","abc123","my_db");
  $res =  mysqli_query($con,"SELECT * FROM text");
  while ($row = mysql_fetch_assoc($res))
 {
     $string[] = $row['text'];
 }
  foreach ($string as $y)
 {
  similar_text($x, $y, $percent);
 }
  if ($percent>"90")
 {
   echo $string ; 
  ?>

i think the above code has many mistakes. i welcome some new solution for my task.

vaibhav
  • 13
  • 4
  • I'm not sure if it matters in PHP, with juggling types and all, but should `"90"` just be `90`? – Andrew Cheong Jun 14 '13 at 11:36
  • This problem is not trivial at all. I would recommend [this question](http://stackoverflow.com/questions/5322917/how-to-compute-similarity-between-two-strings-in-mysql) as a good starting point. You should prefer this kind of approach, ie. filter the results at database level. It is highly inefficient to load a large amount of data into PHP for later processing. – RandomSeed Jun 14 '13 at 12:46
  • @acheong87 it should be 90. – vaibhav Jun 14 '13 at 13:30

0 Answers0