V
V
viktorross2019-11-09 23:29:52
MySQL
viktorross, 2019-11-09 23:29:52

How to make a record in 2 mysql tables?

Hello, please tell me how to do it right
, I have 2 codes,
this one gets the user's email from the table

static function getEmail($id='') {

    global $db;
    if(!$id) return;
    $email=$db->fetchRow('select email from '.TABLE_USERS.' where id="'.$id.'"');
    return $email;
  }

and this one adds an entry to the database when someone clicks on banners
function addHit($id=0) {

    global $db;
    if(!$id) $id=$this->id;
    $res_del=$db->query('update '.TABLE_BANNERS.' set `clicks` = `clicks`+1 where `id`="'.$id.'"');
    return 1;
  }

how do I substitute email from the first $ email when executing the second script and put it in the third table, for example
, class_click in the email line, and each time function addHit is executed, a new entry will be added to the database in the class_click table

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Fedoseev, 2018-10-15
@martin74ua

well, for example, that the mysql server is not running

D
Dmitry Tarasov, 2019-11-09
@fast-je

I don't understand what the problem is to call the getEmail method in the addHit function and store the email in a variable and do whatever.
What does 2 codes mean?
Made very unclear.
And don't use global $db; globals are always bad.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question