|
How To Merge 2 Tables In 1 Table
i have a mysql table titled `films2` has
`id` | `name` | `categorie` | `synopsis` | `type` | `s`and the new table that i want to merege it has `liens` `idlien` | `lien` | `name` i want the table 2 in the `films2` table if the name of the film in the table one equal the name of the film in the table 2
1 Answer
first you have to make new field in the `films2` and name it `lien`, ok?
then you have to use this code: you have to connect with your mysql first $db = @mysql_connect(\'localhost\', \'root\', \'\'); @mysql_select_db(\'filmdest_data\', $db);and then use this code
$liens = @mysql_query(\"select * FROM `liens` order by idlien desc\");
while($lien = mysql_fetch_array($liens)) {
$name = str_replace(\"@\", \"\'\", $lien[\'name\']);
$films2 = @mysql_query(\"select * FROM
`films2` where
`name` LIKE \'%$name%\'\");
$film = mysql_fetch_array($films2);
if ($film) {
if(mysql_query(\"update `films2`
set `lien` = \'\".$lien[\'lien\'].\"\'
where id = \'\".$film[\'id\'].\"\'\")){
echo \'the film no(\'.$film[\'id\'].\') is updated <br>\';
}
}else{
echo \'there is an error with \'.$name.\' and \'.mysql_error();
}
}
Posted: MacOS 2 of 2 people found this answer helpful. Did you? Yes No great !!!
it's working now !!
thank you very much |
© Advanced Web Core. All rights reserved

