我正在创建一个页面,它可以从论坛上获取注册会员的联系方式。我在尝试检索自定义字段时遇到了一个小问题。对于大学和航班,使用下拉菜单,以便用户可以从特定列表中进行选择。但是论坛使用 3 个不同的表来存储数据。这是表格的一小部分
db 模拟 http://www.emuas.co.uk/images/db_mock_up.png
目前我得到了 uni 查询的 uni 和航班查询的航班,但结果与 user_id 无关。不知道如何改变它。
$user = "SELECT *
FROM profile_fields_data
JOIN users
ON profile_fields_data.user_id = users.user_id
ORDER BY users.username";
$uni = "SELECT *
FROM profile_fields_data
JOIN users
ON profile_fields_data.user_id = users.user_id
JOIN profile_fields_lang
ON profile_fields_data.pf_university = profile_fields_lang.option_id
WHERE field_id =4
ORDER BY users.username";
$flight = "SELECT *
FROM profile_fields_data
JOIN users
ON profile_fields_data.user_id = users.user_id
JOIN profile_fields_lang
ON profile_fields_data.pf_flight = profile_fields_lang.option_id
WHERE field_id =3
ORDER BY users.username";
$userdata = $db->sql_query($user);
$unidata = $db->sql_query($uni);
$flightdata = $db->sql_query($flight);
while($data = $db->sql_fetchrow($userdata))
{
$datauni = $db->sql_fetchrow($unidata);
$dataflight = $db->sql_fetchrow($flightdata);
echo "<tr>
<td> <a href='http://emuas.co.uk/forum/memberlist.php?mode=viewprofile&u=" . $data['user_id'] . "'>" . $data['username'] . "</a></td>
<td> <a href='mailto:" . $data['user_email'] . "'>" . $data['user_email'] . "</a> </td>
<td>" . $data['pf_contact_number'] . "</td>
<td>" . $data['user_birthday'] . "</td>
<td>" . $data['pf_service_number'] . "</td>
<td>" . $datauni['lang_value'] . "</td>
<td>" . $dataflight['lang_value'] . "</td>
<td>" . $data['pf_secondary_duty'] . "</td>
</tr>";
非常感谢