aro*_*n n 0 php mysql while-loop
表 persons
name | details
------------------
mathew| tax,home,car,insurance
john | job,tax,employ
neil | tax,home,car,job
yancy | consultant,rent,family
lucy | home,car,insurance
Run Code Online (Sandbox Code Playgroud)
我希望循环遍历此表并搜索详细信息,然后将结果保存到另一个名为的表中 persons1
name | names
------------------
mathew| neil,lucy,john
neil | mathew,lucy,john
john | mathew,lucy,neil
Run Code Online (Sandbox Code Playgroud)
到目前为止,我编写了类似下面但不起作用的内容
mysql_connect("localhost", "root", "pass");
mysql_select_db("database");
$query = "SELECT * FROM persons";
$result = mysql_query($query);
while($r = mysql_fetch_array($result))
{
$exp = explode(",",$r["details"]);
$sql = mysql_query('SELECT * FROM persons WHERE MATCH (tags) AGAINST ("+$exp[0]" "+$exp[1]" "+$exp[2]" IN BOOLEAN MODE)');
$result = array();
while($row = mysql_fetch_assoc($sql))
{
array_push($result,$row['name']);
$name = implode(",",$result);
mysql_query("INSERT INTO person_new (name,names) VALUES (\"".$r["name"]."\", \"".$name."\")");
}
}
Run Code Online (Sandbox Code Playgroud)
很遗憾没人能回答我关于我的代码的问题.而不是查看我的设计我要求你查看我的代码并告诉我在哪里犯了错误..我正在做的事情与它看到的不同,这就是为什么我要求你检查我的代码......