There's nothing 'wrong' with it, it's just not doing what you think it should.
Manuals can be such fun if you only bothered to read them a bit.
mysql_fetch_array() fetches ONE row from the database.
If you want to get more rows, you'll have to do mysql_fetch_array() as many times as it takes.
I guess what you are looking for is this:
$sql="SELECT DISTINCT search1
FROM yp
WHERE search1 LIKE '%$keys%'
ORDER BY search1";
if ($result=mysql_query($sql))
{
$all=array();
while ($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$all[]=$row['search1'];
};
echo implode('&', $all);
}
else
{
echo "SQL Error: ".mysql-error();
}