I was getting distinct values before I gave the % symbol in regular expression for searching.

Here is my code.entries.

$arr = [];
if(isset($_GET['pat']))
    $x = $_GET['pat'].'%';
else
    $x = '%';

$result = mysqli_query($con, "SELECT distinct university FROM colleges WHERE university LIKE '%".$x."%';");
while($row = mysqli_fetch_array($result))
    array_push($arr,$row['university']);

echo json_encode($arr);

How will I get distinct values? I don't want duplicates.

0

There are 0 answers