-3

我对 mysql 搜索查询有一个小问题,我需要制作一个显示所有相似名称的搜索查询 php 脚本,例如:如果在结果中找到 100 个相似名称,则必须显示 100 个结果。

这是我的搜索查询系统脚本。

$result = mysql_Query("SELECT user FROM `UserData` WHERE user LIKE '%$username%'") or die(mysql_error());
        $fetch = mysql_num_rows($result);           

        if( $fetch > 0 )
        {                   
            $resultgg = mysql_Query("SELECT user FROM `theusers` WHERE user LIKE '%$username%' ORDER BY `user` ASC LIMIT 500") or die(mysql_error());
            $row = mysql_fetch_row($resultgg);
            $users = $row[0];               
            echo "$users";                  
        }
               }
    else 
    {
            echo "<br><b>Please Enter Valid Username!</b>";
    }

请帮我。

4

1 回答 1

0
mysql_fetch_row()

returns only 1 column of the resultset (see PHP docs). You need to iterate through the rows.

Visit the PHP documentation for mysql_fetch_row

于 2012-10-28T23:10:26.873 回答