Search code examples
phpmysqlfloating-pointwhere-clausesql-like

MYSQL PHP - get float LIKE $float


I want to get rows with floats like my $float.

I used this code:

$float = $_GET['float'];

$requst = mysql_fetch_array(mysql_query("SELECT * FROM floats WHERE float LIKE'$float.%%%%%%%'"));

then I echoed all the rows with while:

while ($r = $request) {

    echo $a['float'];

}

but the page doesn't show anything. (YES, I typed in the address bar ?float=34 and there are floats like 34.****** in the table.)

What is the problem?

(PHP version 5.2, MYSQL version 5.0)


Solution

  • Try This

    $requst = mysql_query("SELECT * FROM floats WHERE float LIKE'$float.%%%%%%%'");
    while ($r = mysql_fetch_array($request)) {
    
        echo $r['float'];
    
    }