我在数据库中创建了 3 个具有多对多关系的表。我的数据库中的变量$refernece_keys
应该返回数据库中的所有相关字段 - 但它只返回第一个分配的字段并忽略其他字段。
e.g. page1 should return keys_href: id's 1, 2, 3, 4, 8, 10, 15 - however it only returns id:1
page2 should return keys href: id's 3, 4, 5, 7, 8, 11 - however it only returns id:3
我的 ARRAY 有问题吗?
$SQL =
"SELECT * FROM learn_more AS lm
LEFT JOIN learn_more_to_reference_key AS lmtrk
ON lm.id = lmtrk.learn_more_id
LEFT JOIN reference_keys AS rk
ON rk.keys_id = lmtrk.reference_key_id
WHERE lm.page_title = '$this_page'";
$result = mysql_query($SQL) or die(mysql_error());
while ($db_field = mysql_fetch_array($result))
{
$id = $db_field['id'];
$main_title = $db_field['main_title'];
$main_content = $db_field['main_content'];
$reference_keys = $db_field['keys_href'];
$sub_title = $db_field['sub_title'];
$sub_content = $db_field['sub_content'];
}
------------------------------------------------>编辑
我的 PHP 视图页面是一个模板
<div id="content">
<div class="section_frame">
<div class="section_title">
<?php echo $main_title; ?>
</div>
<div class="section_content">
<?php echo $main_content; ?>
</div>
<div class="section_content_ref">
<span class="hl_reference"><u>key references:</u></span>
<?php echo $reference_keys; ?>
</div>
<div class="sub_section_title">
<?php echo $sub_title; ?>
</div>
<div class="sub_section_content">
<?php echo $sub_content; ?>
</div>
所以基本上我只想让我的价值观得到回应..