'Querying "fid"s for executing a task in MyBB

The task below overwhelms my PHP skills. That's why I'm asking for help here.

In the MyBB forum, when registering, users must:

  1. Provide a 5-digit invoice number.

The information is stored in the mybb_userfields table in the fid8 column.

  1. Enter text (letters)

The information is stored in the mybb_userfields table in the fid10 column.

In a task (mentally ... the examples below do not work) should be processed as follows:

A) with IF conditions?

(FID8)

if (fid8 >= 1 && fid8 <= 49999) {
$query = $db->query("UPDATE mybb_users SET additionalgroups = '8,9'");
}

etc.

B) with WHERE conditions?

FID8

$query = $db->query("UPDATE mybb_users SET additionalgroups = '8,9' WHERE fid8 >= '1' && fid8 <= '49000'");

etc.

How do you have to define the fields "fid8" and "fid10" (and others) beforehand so that something can be done with the values ​​(see examples above)?

Many thanks in advance for tips and hints. (Translate with Google Translater)


Solution (example):

$db->query("UPDATE mybb_users u LEFT JOIN mybb_userfields f ON f.ufid = u.uid SET usergroup = '4' WHERE f.fid8 = 'xxx'");

Thanks to ExiTuS on MyBB.de



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source