There are 4 tables interconnected by id hierarchically users-> phones-> sites-> tax and there is an incoming data array in which there is a column of the formsite.rusite2.rusite3.ru1234568967654456876
Each user also has a cash account column. How to make a request that would go through the incoming array and, if the data from the column with attached data matches, each user (phone number or website) withdrew the tax clogged in the tax table (the tax is linked only to the site). I can’t think of such a search with simultaneous comparison and updating of account data. If you have clarifying questions ask may have given an incomplete picture.
Here is what happened as a result:
$query2 = mysql_query("SELECT id FROM users WHERE id NOT IN (1,2)"); while ($sub_money2 = mysql_fetch_array($query2)) { $query3 = mysql_query("SELECT users.id, users.money, phones.phone, site.url, rates.taxes FROM users LEFT JOIN phones ON users.id = phones.user_id LEFT JOIN site ON phones.id = site.phones_id LEFT JOIN rates ON site.id = rates.site_id WHERE users.id = {$sub_money2['id']}"); while ($sub_money3 = mysql_fetch_array($query3)) { $sub3_result[] = $sub_money3; foreach ($sub1_emailFrom as $sub1) { foreach ($sub3_result as $sub3) { if (($sub3['phone'] == $sub1) || ($sub3['url'] == $sub1)) { $query4 = mysql_query("UPDATE users SET money = ({$sub3['money']} - {$sub3['taxes']}) WHERE users.id = {$sub3['id']}"); echo "Обновление у юзера:" . $sub3['id'] . " баланс равен:" . $sub3['money'] . "<br/>"; } } } } } There remains only the question of how to do it so that after each successful IF (tobish when the funds were removed from the balance, the balance was updated and in the future the funds were removed from the new balance immediately every time there is a withdrawal from the initial amount)
"site.ru" in(table_a.site, table_b.phone,...). And then convert it to update .... - Mike