Comparison of Mysql data from two different banks - PHP

1

My web application should access two different banks on different servers, put the column of the two banks on the screen and compare the result between them.

However, it only returns the value of one of the banks and the other it returns all zero, according to the image.

while($line=mysql_fetch_array($table_primal1)&&$lineup=mysql_fetch_array($table_primal2)){$convert2=(float)$line['campo016'];$convertup=(float)$lineup['campo016'];if($convertup==$convert2){$compara='Correto';$printtr='trcorrect';$printtd='correct';}else{$compara='Erro';$printtr='trerror';$printtd='error';}echo'<trclass='.$printtr.'>';echo'<tdclass='.$printtd.'>'.$line['papel'].'</td>';echo'<tdclass='.$printtd.'>'.$line['campo036'].'</td>';echo'<tdclass='.$printtd.'>'.$convert2.'</td>';echo'<tdclass='.$printtd.'>'.$convertup.'</td>';echo'<tdclass='.$printtd.'>'.$compara.'</td>';echo'</tr>';

Thecodeyoushoulddoallthisisbasicallythis.Itriedputtingonewhileinsideanother,butitonlyreturnsmethefirstresultoftheothercolumnanddpsrepeats.

FollowmyQuerys:

$table_primal1=mysql_query("SELECT * FROM quotes where origem='30' and papel like 'ZS_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_9' AND campo012 >= '0' AND campo016 >='0' ORDER BY papel ASC",$conexao_ori30a);

  $table_primal2 = mysql_query("SELECT * FROM quotes where origem='30' and papel like 'ZS_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_9' AND campo012 >= '0' AND campo016 >='0' ORDER BY papel ASC", $conexao_ori30b);
    
asked by anonymous 15.09.2017 / 17:06

1 answer

0

I just discovered the answer unknowingly kkk, I'll post here if anyone ever has the same problem.

Instead of putting $ line_up = mysql_fetch_array ($ table_primal2) in some while, I simply threw it along with the values that would be fetched by the table and worked.

while ($line = mysql_fetch_array($table_primal1) ) {
    $line_up= mysql_fetch_array($table_primal2)

$convert2 = (float) $line['campo016'];
$convertup = (float) $lineup['campo016'];       
if($convertup==$convert2){
$compara = 'Correto';
$printtr = 'trcorrect';
$printtd = 'correct';
} else {
$compara = 'Erro';
$printtr = 'trerror';
$printtd = 'error';
}

echo'<tr class='.$printtr.'>';
echo'<td class='.$printtd.'>'  .$line['papel'].  '</td>';
echo'<td class='.$printtd.'>'  .$line['campo036'].  '</td>';
echo'<td class='.$printtd.'>'  .$convert2.  '</td>';
echo'<td class='.$printtd.'>'  .$convertup.  '</td>';
echo'<td class='.$printtd.'>'  .$compara.  '</td>';     
echo'</tr>'; 
    
15.09.2017 / 18:39