Dear colleagues,
I have the following situation:
BD 01
ID | DESCRICAO | DRADS
1 | REGISTRO1 | 1,2,3
2 | REGISTRO2 | 1
BD 02
ID | DESCRICAO | DRADS
1 | REGISTRO1 | 1,2
2 | REGISTRO2 | 1
It is necessary to make a <select></select>
by pulling only the BD 01 records that have the same DRADS of the BD 02 ... That is, the BD 01 will only be able to select the record (s) ) with the same DRADS (s) of DB 02.
The values of DB 01, I get through a while(...)
. As for the values of DB 02, I get through $_SESSION['BD_02_DRADS']
.
I have tried to compare the $_SESSION['BD_02_DRADS'] + $row['BD_01_DRADS']
values with the in_array()
and array_diff()
functions but I could not get the result I need.
Using in_array()
, results that have more than one DRADS appear duplicate.
Using array_diff()
, I can only display <select></select>
if the DRADS are identical.
I do not know if I could be clear enough, but I'll try to leave an example of what I need below:
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$BD_01_DRADS = explode(",", $row['BD_01_DRADS']);
$BD_02_DRADS = explode(",", $_SESSION['BD_02_DRADS']);
$array1 = $BD_01_DRADS;
$array2 = $BD_02_DRADS;
}
So I need the following condition: SE TIVER $BD_01_DRADS EM $BD_02_DRADS, EXIBE UM <option>...</option> dentro do <select></select> com os respectivos dados deste registro
.
Guys, I apologize if I was not clear enough. But I am available for any clarification.
Any and all help is welcome.
Thank you all!