0

如果它们在数组中,如何使用先前查询的结果查询数据库?以下是我到目前为止所拥有的。

$query = "SELECT * from searchtestdb where engname in ( SELECT synonyms.synonym  FROM words  LEFT JOIN synonyms ON synonyms.word_id = words.word_id WHERE word LIKE '%$searchBox%') ";

while($result = mysql_fetch_array($query)) 
        {
            echo $result['engname'];
            echo "<br> ";
            echo "<br> ";
        }

如何获取 $result['engname'] 并再次查询?我在想类似的东西

SELECT * from searchtestdb where engname LIKE '%$result['engname']%';

但这显然行不通。有任何想法吗?

4

1 回答 1

2
while($result = mysql_fetch_array($query)) 
{
   $query2 = "SELECT * from searchtestdb where engname LIKE '%".$result['engname']."%';";
   $result2 = mysql_query($query2);
   while($row = mysql_fetch_array($result2)) 
   {
       echo $row["somthing"];
   }
}
于 2013-04-20T06:30:16.677 回答