table 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
I want loop through this table and search with details then saved result to another table called persons1
name | names
------------------
mathew| neil,lucy,john
neil | mathew,lucy,john
john | mathew,lucy,neil
so far I coded something like below but not working
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."\")");
}
}
IT is very sad that nobody can give an answer to my question about my code. instead of looking into my design I request you to look into my code and tell me where I made a mistake..i am doing something different than what it sees and this is why I request you to check my code...