0

I have database structure like this: Table tickets: -- Main table id | no | building_code Table addresses: -- Secondary table employee_id | building_id

In the PHP code i must to get data for certain user from global table tickets and compare answer with addresses. I want to get association from table addresses wish that columns and compare that table with tickets.

I want to send to certain user message with only his tickets by ticket ID (building_id). But i cant create condition to send certain ID's to the user.

My code

$db = new mysqli($mysql['host'], $mysql['user'], $mysql['password'], $mysql['database']) or die ($db->error()); // связь с БД
 
$users_raw = $db->query("select * from `tg_users`");
$addresses_raw = $db->query("select * from `addresses`");
$tickets_raw = $db->query("select * from `ticket_itera`");
$tickets_sended_raw = $db->query("select * from `tickets_sended`");

//$addresses = $addresses_raw->fetch_all();

if ($debug) {
    ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
}

function tg($method)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.telegram.org/xcxzcxcxc/" . $method);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
    curl_exec($ch);
    curl_close($ch);
}


while ($ticket = $tickets_raw->fetch_array())
{
    while ($addr = $addresses_raw->fetch_array())
    {
        tg("sendMessage?chat_id=$addr[employee_id]&text=$addr[address]"); break;
    }
}
thescs
  • 51
  • 4
  • **[You should not switch off `CURLOPT_SSL_VERIFYHOST` or `CURLOPT_SSL_VERIFYPEER`](https://paragonie.com/blog/2017/10/certainty-automated-cacert-pem-management-for-php-software)**. It could be a security risk! [Here is how to get the certificate bundle if your server is missing one](https://stackoverflow.com/a/32095378/1839439) – Dharman Sep 25 '20 at 15:40
  • You are yet to ask a question here. What is the problem that you are having with this code? – GMB Sep 25 '20 at 17:36

0 Answers0