I am trying to format my table so that the rows have 2 lines of data like below:

1234 John Doe
anything anything anything

here is my $rows[]


$rows[] = array(l(t('View'), "user/$records->nid/edit", array(), $destination) , $records->client_fname, $records->client_lname);

I have been trying to add <br> with no success. I am still having trouble figuring out the syntax. Can someone please help with an example of how to correct this code. Also any suggestions on further reading on how to do this kind of stuff i.e. format tables and sql output would be appreciated. I have read theme_tables but it is very brief and lacking in practical examples. At least as far as I can understand.

Thanks in advance for the help.

Comments

nevets’s picture

Each array element represents one column in the table, the example you show would be a three column table. To do what you want you would combine data something like this.

<?php
$column = '1234' . 'John' . 'Doe' . '<br />';
$column .= 'anything anything anything';
$rows[] = array(l(t('View'), "user/$records->nid/edit", array(), $destination), $column);
?>

Which would give you a two column table. You can of course use data instead of constants so the first line of the example above combined with you example might read

<?php
$column = '1234' . $records->client_fname . ' ' . $records->client_lname . '<br />';
?>
slamMan’s picture

Your code was dead on, you just didn't quite get what I meant. However I was able to solve my problem by seeing what you did. Here is my code maybe there is a more elegant way to do it.

$column1 = '1234 <br />';
$column1 .= 'anything';
$column2 = 'John <br />';
$column2 .= 'anything';
$column3 = 'Doe <br />';
$column3 .= 'anything';
$rows[] = array(l(t('View'), "user/$records->nid/edit", array(), $destination), $column1, $column2, $column3);

This gave me the results I was looking for, and your code made it easier than I anticipated.

Thanks for the help again.

funkioto’s picture

This looks like what I need for my table but when I place this code in a Story I get no output?

Am I not doing something simple like a print statement at the end?

Thanks

funkioto’s picture

I'm using the Tables module now, it does what I require.

http://www.webgeer.com/tables_demo