I have a table that is the result of a MySQL query of a database on a server. It is shown as follows, for example:
E-MAIL VALUE
------ -----
email1 P
email2 P
email3 C
email4 P
email5 C
email6 P
I need to get the value of the second column (P or C) when the user logs in with one of the emails from this table.
Assuming then that the user is the email5, he has to get the value C. After getting the value C, this value will be inserted into another table (MySQL database) of the server of my page.
I do not know if it was very clear. My initial idea was to take value from a table of one MySQL database (from server 1) and put it in another table from another MySQL database (from server 2), but so far I did not succeed.
Probably the function will have to be in javascript. But if it can be done in PHP it would be better.
EDIT - The code I tried with quick access to both banks:
$emailInv = $this->email;
$sqlNuevo = "SELECT DISTINCT uh.TIPO_INVESTIDOR FROM ipi_tst.uh
JOIN ipi_tst.investidor i ON i.ID = uh.ID_INVESTIDOR
JOIN ipi_tst.usuario u ON u.ID = i.ID_USUARIO
WHERE u.EMAIL = '$emailInv' AND u.ID <> 0 ORDER BY FIELD(TIPO_INVESTIDOR,'P','C','O','A')";
$conn = new mysqli("201.7.201.173", "ipi_tst", "ipi_tst", "ipi_tst");
$rNew = $conn->query($sql);
if ($rNew[0]['TIPO_INVESTIDOR'] == 'O'){
$sqlUpd = "UPDATE b2c.investidor SET office = '1' WHERE email = '$emailInv' AND ID <> 0";
$res = System::element('db')->query($sqlUpd);
}
else if ($rNew[0]['TIPO_INVESTIDOR'] == 'A'){
$sqlUpd = "UPDATE b2c.investidor SET office = '2' WHERE email = '$emailInv' AND ID <> 0";
$res = System::element('db')->query($sqlUpd);
}
else {
$sqlUpd = "UPDATE b2c.investidor SET office = '0' WHERE email = '$emailInv' AND ID <> 0";
$res = System::element('db')->query($sqlUpd);
}
$conn->close();