Hello all,
I have the following custom code in my events tab.
With this code I get my results grouped by year:
1992
---------
january 1992
februari 1992
march 1992
1991
---------
january 1991
februari 1991
march 1991
The second thing I would like to do is displaying the data not verticaly, but horizontally. Like:
1992
---------
january 1992 februari 1992 march 1992
1991
---------
january 1991 februari 1991 march 1991
But how do you do this? In my code above the column part isn't working, but I can't figure out what.
Regards,
Ruud
I have the following custom code in my events tab.
<table>
<?php
$jaartal = '';
foreach($form->data['ACE'] as $record):
{
if( $jaartal != $record['jaartal'] )
{
echo "<tr><td id='jaartal'>".( $record['jaartal'] )."</td></tr>";
$jaartal = $record['jaartal'];
}
}
$columns = 2; //No of column
$dataToDisplay = array($record['naam']);
$columnwidth = 100/$columns;
$count = count($dataToDisplay);
$i =0;
foreach($dataToDisplay as $data) {
if($i % $columns == 0){
echo "<tr>";
}
echo "<td>" . $data . "</td>";
if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows){
echo "</tr>";
}
$i++;
}
endforeach;
?>
</table>
With this code I get my results grouped by year:
1992
---------
january 1992
februari 1992
march 1992
1991
---------
january 1991
februari 1991
march 1991
The second thing I would like to do is displaying the data not verticaly, but horizontally. Like:
1992
---------
january 1992 februari 1992 march 1992
1991
---------
january 1991 februari 1991 march 1991
But how do you do this? In my code above the column part isn't working, but I can't figure out what.
Regards,
Ruud
Hi Ruud,
I think you probably need a colspan set in this line
Bob
I think you probably need a colspan set in this line
echo "<tr><td colspan='3' id='jaartal' >{$record['jaartal']}</td></tr>";
Otherwise your table only has one column.Bob
Hi Bob,
That didn't work for me.
But I found out that in the code there is the $num_rows. But nowhere in the code is something with $num_rows so I place the following code after <?php:
But this also didn't work๐
That didn't work for me.
But I found out that in the code there is the $num_rows. But nowhere in the code is something with $num_rows so I place the following code after <?php:
$db =& JFactory::getDBO();
$query = "SELECT * FROM ace_database";
$db->setQuery($query);
$db->query();
$num_rows = $db->getNumRows();
But this also didn't work๐
After some searching and testing I got it working.
But for some kind of reason the last part of the code isn't working.
I made a CSS border around the TD-element and I saw that every record is loaded within 1 TD-element (instead of each record in a seperate TD-element).
Anyone any ideas how to get this working?๐
<?php
$db =& JFactory::getDBO();
$query = "SELECT * FROM ace_database";
$db->setQuery($query);
$db->query();
$num_rows = $db->getNumRows();
$result=$db->loadAssocList();
$x = 0;
$num_cols = 4;
echo $num_rows;
echo $num_cols;
echo "
<table cellpadding='0' cellspacing='0' border='1' width='100%' >";
echo "
<tr>
<td valign='top' width='25%' id='tabel'>";
foreach($result as $results)
{
echo $results['naam'];
}
$x++;
if ($x == ceil($num_rows / $num_cols)) {
echo "
</td>
<td valign='top' width='25%'>";
$x = 0;
}
echo "
</td>
</tr>
</table>";
?>
But for some kind of reason the last part of the code isn't working.
$x++;
if ($x == ceil($num_rows / $num_cols)) {
echo "
</td>
<td valign='top' width='25%'>";
$x = 0;
I made a CSS border around the TD-element and I saw that every record is loaded within 1 TD-element (instead of each record in a seperate TD-element).
Anyone any ideas how to get this working?๐
This topic is locked and no more replies can be posted.