我想插入“这pple,是一种果实”,来查询数据库,只能与数据库中未果的 words和水果相匹配,并交还1个水果 red。
如何修改询问法?
数据库名称食品领域如下:
id name1 name2 name3 name4 type
1 fruit apple red 10 article
2 fruit banana yellow 12 article
3 drink beer yellow 6 article
4 fruits apple yellow 16 books
法典:
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("article") or die(mysql_error());
... ...
echo $match . "r"; // $match= This is a apple, it is a fruit
$query = mysql_query("SELECT * FROM food WHERE name1, name2 like %$match% ");
$row=mysql_fetch_array($query);
echo $row[ id ]. "r" .$row[ name1 ]. "r".$row[ name2 ]. "r".$row[ name3 ]. "r".$row[ name4 ]. "n";