【问题标题】:How to populate footer in bottom of the table - using PHP drupal 7如何在表格底部填充页脚 - 使用 PHP drupal 7
【发布时间】:2020-06-17 01:48:54
【问题描述】:

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

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

这是我的功能:

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 循环上方,它会在表格顶部显示值,但会显示空值。

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

【问题讨论】:

    标签: php foreach drupal-7 footer


    【解决方案1】:

    $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;
    

    【讨论】:

    • 嘿@Fky 我不明白 $rows = array(0 => '将被值替换');哪些价值观?我在 foreach 中传递?
    • 你在吗可以指导我。
    • $rows = array(0 => null);它是一样的,只是将第一个值初始化到数组中,所以接下来当你使用 $rows=[] 索引将是 1 、 2 等......所以在你的循环之后,你将插入 à 0 索引总和放置它在数组的第一行
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-12
    • 2011-03-14
    • 1970-01-01
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多