Can someone tell me how to do it right? I tried on the principle of zar.name_zar and products.user, but unfortunately there are duplicate entries on this principle. To be clear, I need to output a list from products with a match from zar: $ resultA is the products table and resultB is the zar table.
if($resultA['ID'] == $resultB['id_zar']){$oplata = $resultB['price_zar'];} else{$oplata = "Не оплачено";} Here is the full code:
mysql_query("SET NAMES utf8"); $sqlA = mysql_query("SELECT * FROM `products` WHERE user LIKE '%".$rname."%' ORDER BY ID DESC", $link); $sqlB = mysql_query("SELECT * FROM `zar` WHERE name_zar LIKE '%".$rname."%' ", $link); $resultA=mysql_fetch_array($sqlA); $resultB=mysql_fetch_array($sqlB); while ($resultA .$resultB) { if($resultA['ID'] == $resultB['id_zar']){$oplata = $resultB['price_zar'];} else{$oplata = "Не оплачено";} $oplata; echo '<tr>'. '<td><a href="/id.php?red_id='.$result['ID'].'"><i class="fa fa-file-text"></i></a></td>'. '<td>'.$result['ID'].''. '<td>'.$result['data'].'</td>'. '<td>'.$result['Tech'].'</td>'. '<td>'.$result['status'].'</td>'. '<td>'.$result['end'].'</td>'. '<td>'.$oplata.'</td>'. '</tr>' ; }