- #1
Robbie8
- 3
- 0
Postby Robbie8 » Mon Sep 03, 2012 7:44 pm
Hi,
I am using a php view to show a table of all the entrants in my projects with their number, name, rounds and points.
I have two projects Project One and Two which have their results displayed in tables. The width of the columns for the values in these projects are dependent on the size of the name of the person, or club or points, making the table views slightly offset. The data records are read from a mysql database tables
i.e if the name is Fred Bloggs then the name column is only 11 characters wide, whereas if the name is Frederick Wilkinson then the column is 20 characters wide.
If Fred Bloggs is in project one and Frederick Wilkinson is in Project two, then when they are viewed on the web page then the Table for Project one is not as wide as for project two, making them look offset and not professional.
I would like to be able to define the width of each field, so as an example let's say the name field to be 25 characters and be padded with blanks if the name is shorter. Yes I understand that if the name was 26 characters it would be truncated and accept that, but as my individuals are fixed, I can live with that.
The php code is displayed below, but I don't know how to amend it to fix the column widths and would really appreciate some advice.
--
<?php
defined('_JEXEC') or die('Restricted access'); ?>
<div id="Plans">
<h1><?php echo $this->title; ?></h1>
<table class="raceResults" cellspacing="0" cellpadding="0" summary="">
<thead>
<tr>
<th><?php echo JText::_('COM_Plans_POSITION_SHORT' ); ?></th>
<?php if ($this->params->get('shownumber')): ?>
<th><?php echo JText::_('COM_Plans_NUMBER_SHORT' ); ?></th>
<?php endif; ?>
<th><?php echo JText::_('COM_Plans_Individual' ); ?></th>
<?php if ($this->params->get('showteams')): ?>
<th><?php echo JText::_('COM_Plans_Team' ); ?></th>
<?php endif; ?>
<?php foreach ($this->rounds as $r): ?>
<th colspan="<?php echo count($r->subrounds); ?>" class="hasTip" title="<?php echo $r->round_name; ?>"><?php echo substr($r->short_name, 0, 6); ?></th>
<?php endforeach; ?>
<th><?php echo JText::_('COM_Plans_Points' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach( $this->rows AS $ranking )
{
$link_ind = JRoute::_( PlansHelperRoute::getIndividualRoute($ranking->slug, $this->project->slug) );
$link_team = JRoute::_( PlansHelperRoute::getTeamRoute($ranking->teamslug, $this->project->slug) );
?>
<tr class="<?php echo ($i ? 'd1' : 'd0'); ?>">
<td><?php echo $ranking->rank; ?></td>
<?php if ($this->params->get('shownumber')): ?>
<td><?php echo $ranking->number; ?></td>
<?php endif; ?>
<td>
<a href="<?php echo $link_ind; ?>"
title="<?php echo JText::_('COM_Plans_Details' ); ?>">
<?php echo $ranking->first_name . ' ' . $ranking->last_name; ?>
</a>
</td>
<?php if ($this->params->get('showteams')): ?>
<td>
<?php if ($ranking->team_id): ?>
<a href="<?php echo $link_team; ?>"
title="<?php echo JText::_('COM_Plans_Details' ); ?>">
<?php echo $ranking->team_name; ?></a>
<?php endif; ?>
</td>
<?php endif; ?>
<?php $i = 1;?>
<?php foreach ($this->rounds as $round): ?>
<?php foreach ($round->subrounds as $subround): ?>
<td><?php echo isset($ranking->results[$subround->subround_id]) ? $ranking->results[$subround->subround_id] : '-'; ?></td>
<?php endforeach; ?>
<?php endforeach; ?>
<td><?php echo $ranking->points; ?></td>
</tr>
<?php
$i = 1 - $i;
}
?>
</tbody>
</table>
<p class="copyright">
<?php echo HTMLplans::footer( ); ?>
</p>
</div>
Hi,
I am using a php view to show a table of all the entrants in my projects with their number, name, rounds and points.
I have two projects Project One and Two which have their results displayed in tables. The width of the columns for the values in these projects are dependent on the size of the name of the person, or club or points, making the table views slightly offset. The data records are read from a mysql database tables
i.e if the name is Fred Bloggs then the name column is only 11 characters wide, whereas if the name is Frederick Wilkinson then the column is 20 characters wide.
If Fred Bloggs is in project one and Frederick Wilkinson is in Project two, then when they are viewed on the web page then the Table for Project one is not as wide as for project two, making them look offset and not professional.
I would like to be able to define the width of each field, so as an example let's say the name field to be 25 characters and be padded with blanks if the name is shorter. Yes I understand that if the name was 26 characters it would be truncated and accept that, but as my individuals are fixed, I can live with that.
The php code is displayed below, but I don't know how to amend it to fix the column widths and would really appreciate some advice.
--
<?php
defined('_JEXEC') or die('Restricted access'); ?>
<div id="Plans">
<h1><?php echo $this->title; ?></h1>
<table class="raceResults" cellspacing="0" cellpadding="0" summary="">
<thead>
<tr>
<th><?php echo JText::_('COM_Plans_POSITION_SHORT' ); ?></th>
<?php if ($this->params->get('shownumber')): ?>
<th><?php echo JText::_('COM_Plans_NUMBER_SHORT' ); ?></th>
<?php endif; ?>
<th><?php echo JText::_('COM_Plans_Individual' ); ?></th>
<?php if ($this->params->get('showteams')): ?>
<th><?php echo JText::_('COM_Plans_Team' ); ?></th>
<?php endif; ?>
<?php foreach ($this->rounds as $r): ?>
<th colspan="<?php echo count($r->subrounds); ?>" class="hasTip" title="<?php echo $r->round_name; ?>"><?php echo substr($r->short_name, 0, 6); ?></th>
<?php endforeach; ?>
<th><?php echo JText::_('COM_Plans_Points' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach( $this->rows AS $ranking )
{
$link_ind = JRoute::_( PlansHelperRoute::getIndividualRoute($ranking->slug, $this->project->slug) );
$link_team = JRoute::_( PlansHelperRoute::getTeamRoute($ranking->teamslug, $this->project->slug) );
?>
<tr class="<?php echo ($i ? 'd1' : 'd0'); ?>">
<td><?php echo $ranking->rank; ?></td>
<?php if ($this->params->get('shownumber')): ?>
<td><?php echo $ranking->number; ?></td>
<?php endif; ?>
<td>
<a href="<?php echo $link_ind; ?>"
title="<?php echo JText::_('COM_Plans_Details' ); ?>">
<?php echo $ranking->first_name . ' ' . $ranking->last_name; ?>
</a>
</td>
<?php if ($this->params->get('showteams')): ?>
<td>
<?php if ($ranking->team_id): ?>
<a href="<?php echo $link_team; ?>"
title="<?php echo JText::_('COM_Plans_Details' ); ?>">
<?php echo $ranking->team_name; ?></a>
<?php endif; ?>
</td>
<?php endif; ?>
<?php $i = 1;?>
<?php foreach ($this->rounds as $round): ?>
<?php foreach ($round->subrounds as $subround): ?>
<td><?php echo isset($ranking->results[$subround->subround_id]) ? $ranking->results[$subround->subround_id] : '-'; ?></td>
<?php endforeach; ?>
<?php endforeach; ?>
<td><?php echo $ranking->points; ?></td>
</tr>
<?php
$i = 1 - $i;
}
?>
</tbody>
</table>
<p class="copyright">
<?php echo HTMLplans::footer( ); ?>
</p>
</div>