MySQL阵列foreach循环w/smartyphp

MySQL阵列foreach循环w/smartyphp,php,mysql,arrays,smarty,Php,Mysql,Arrays,Smarty,我有两个Medoo.in MySQL查询-1。抓取项目表(id、名称、背景图片、游戏图标),2。抓取信息表(id、名称、项目id),其中项目id=project.id (如果单击带有3个栏的右侧图标,则显示此表格数据) 出于某种原因,foreach循环仅显示SmartyHP中的最后一行数据 <?php /** * Example Application * * @package Example-application */ require '/home/anthony/sites/

我有两个Medoo.in MySQL查询-1。抓取项目表(id、名称、背景图片、游戏图标),2。抓取信息表(id、名称、项目id),其中项目id=project.id

(如果单击带有3个栏的右侧图标,则显示此表格数据)

出于某种原因,foreach循环仅显示SmartyHP中的最后一行数据

<?php
/**
 * Example Application
 *
 * @package Example-application
 */
require '/home/anthony/sites/mmostatus/libs/Smarty.class.php';
require '/home/anthony/sites/mmostatus/current/assets/php/connect.php';

$smarty = new Smarty;
//$smarty->force_compile = true;
$smarty->debugging = false;
$smarty->caching = false;
$smarty->cache_lifetime = 120;

//fetch project id, and monitor details
$project=$database->select("project",[
        "id",
        "name",
        "background_image",
        "game_icon"
]);

foreach($project as $data){
$monitor=$database->select("information",[
            "id",
            "name"
            ],[
            "project_id" => $data['id']
        ]);
}

$smarty->assign("project", $project);
$smarty->assign("monitor", $monitor);
$smarty->display('./templates/index.tpl');
?>

index.tpl

{foreach from=$project key=k item=v}
  <!--Start-->
  <div class="col-sm-12 game-item game-id-{$v.id}">
    <div class="card" style="border-radius: 4px 4px 4px 4px;">
      <div class="bg-gradient position-relative text-white" style="border-radius: 4px 4px 0 0;">
        <img alt="Background Image" class="bg-image opacity-40" style="border-radius: 4px 4px 0 0;" src="{$v.background_image}">
        <div class="h3 m-5 position-relative">
          {$v.name} <img src="{$v.game_icon}" />
          <div style="float:right;" onclick="mmostatus('game-{$v.id}-table');"><img class="icon bg-light" src="assets/img/icons/interface/icon-menu.svg" alt="Icon" data-inject-svg /></div>
        </div>
      </div>
      <!--Table-->
      <div id="game-{$v.id}-table" class="table-responsive" style="display:none;">
        <table class="table">
          <thead>
            <tr>
              <th scope="col">Location</th>
              <th scope="col">Uptime</th>
              <th scope="col">Avg. Response Time</th>
              <th scope="col">Status</th>
              <th scope="col">Last Checked</th>
            </tr>
          </thead>
          <tbody>
            {foreach from=$monitor key=k item=mv}
            <tr>
              <th scope="row">{$mv.name}</th>
            </tr>
            {/foreach}
          </tbody>
        </table>
      </div>
    </div>
  </div>
  {/foreach}
  <!---End-->
</div>
{foreach from=$project key=k item=v}
{$v.name}
位置
正常运行时间
平均响应时间
地位
最后检查
{foreach from=$monitor key=k item=mv}
{$mv.name}
{/foreach}
{/foreach}