Hi,

I created a custom block in a custom module who is displaying data from mySQL database (it's returning a lot of rows).

I wanted to know how can i create a board who is containing the data (for example : name firstname adress in 3 columns, something like that).

Thanks !

Comments

nitin.k’s picture

I created a custom block in a custom module who is displaying data from mySQL database (it's returning a lot of rows).

=> You need to limit the records or if can`t than use paging or load more functionality; please make sure block is scrollable.

I wanted to know how can i create a board who is containing the data (for example : name firstname adress in 3 columns, something like that).

=> You can create a view from back end if not than please follow my first comment.

cofaure’s picture

I'm displaying my data with this code :

 $contenu = array();
    foreach($resul as $row)
    {
      $contenu[] = array('#markup' =>  utf8_encode((string)$row['name'])."  ".utf8_encode((string)$row['firstname'])."  ".(string)$row['mail'].'<br>');
    }

    return $contenu;
Jaypan’s picture

$header = array(t('Username'), t('First Name'), t('Mail'));
$rows = array();
foreach($result as $r)
{
  $row = array();
  $row[] = $row['name'];
  $row[] = $row['firstname'];
  $row[] = $row['mail'];

  $rows[] = $row;
}

return array
(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,
  '#empty' => t('No values found'),
);
cofaure’s picture

Hi !

It works fine for the board but my data are not in, i'm trying to understand why the board is empty

EDIT : its ok i found why ! Thanks anyway !

cofaure’s picture

Thanks guys ill try it tomorrow !