首页 > 解决方案 > 如何在表格底部填充页脚 - 使用 PHP drupal 7

问题描述

我有显示图像并填充图像总目录总查找摘要的功能,总目录和总应解决/总解决

但它显示在页面末尾我想显示在底部我还附上了我的值的屏幕截图,它显示在底部:

这是我的功能:

function _network_drive_test(){
$arguments = arg();
$id = $arguments[count($arguments) - 2];

$query = db_select('network_drive_listing','n');
$query
->fields('n')
->condition('n.network_drive_id',$id)
->orderBy('n.ndlistid');
 $results = $query->execute();

 $header = array(t('Sr no'),t('Image'),t('Public Path'), t('Is Dir'),t('Status'));
 $rows = array();
 $totalFind = 0;
 $totalShouldFind = 0;
 $totalIsDir = 0;
 $totalResolved = 0;
 $forOfor = 0;
 foreach($results as $record) {
  $totalFind++;
  $array = [
  $totalFind,
  $record->public_path !== "" ? '<div style="background-image: url(\'' .   url($record->public_path) . '\'); height: 50px; width:50px;background-size: cover;border-radius: 50%;background-position: center;" />' : '',
  $record->public_path,
  $record->is_dir
];
if ($record->is_dir != 1) {
  $totalShouldFind++;
  $headers = @get_headers($record->public_path);

  // Use condition to check the existence of URL
  if ($headers && strpos($headers[0], '200')) {
    $array['status'] = "URL Exist" . PHP_EOL;
    $totalResolved++;
  } else {
    $array['status'] = "URL Doesn't Exist(" . $record->public_path . ")" . PHP_EOL;
    $forOfor++;
  }

  } else {
     $totalIsDir++;
     $array['status'] = "This is directory" . PHP_EOL;
  }
   $rows[] = $array;
 }
  $array = [
  $form['#prefix'] = '<div class="page_summary" <strong>Summary: </strong>',
  $form['#prefix'] = '<div class="total_find" <strong>Total Find: </strong>'. $totalFind,
  $form['#prefix'] = '<div class="total_dir" <strong>Total Find: </strong>'. $totalIsDir,
  $form['#prefix'] = '<div class="total_should_resolve" <strong>Total Should Resolve</strong>: ' . $totalShouldFind.'<strong> / Total Resolved : </strong>'. $totalResolved,
  $form['#prefix'] = '<div class="error_bar" style="display">404:'.$forOfor,
];
   $rows[] = $array;

 return theme('table', array('header' => $header, 'rows' => $rows));
    }

如果我将 $form 值放在 foreach 循环上方,它会在表格顶部显示值,但会显示空值。

另请参阅我当前显示底部的屏幕截图,我想在顶部显示:

在此处输入图像描述

标签: phpforeachdrupal-7footer

解决方案


更改$rows声明:

$header = array(t('Sr no'),t('Image'),t('Public Path'), t('Is Dir'),t('Status'));
$rows = array(0 => 'will be replaced by values');

[...] 最后修改:

$array = [
  $form['#prefix'] = '<div class="page_summary" <strong>Summary: </strong>',
  $form['#prefix'] = '<div class="total_find" <strong>Total Find: </strong>'. $totalFind,
  $form['#prefix'] = '<div class="total_dir" <strong>Total Find: </strong>'. $totalIsDir,
  $form['#prefix'] = '<div class="total_should_resolve" <strong>Total Should Resolve</strong>: ' . $totalShouldFind.'<strong> / Total Resolved : </strong>'. $totalResolved,
  $form['#prefix'] = '<div class="error_bar" style="display">404:'.$forOfor,
];
   $rows[0] = $array;

推荐阅读