getting individual record numbers?
17 posts by 3 authors in: Forums > CMS Builder
Last Post: December 8, 2009 (RSS)
By Chris - December 7, 2009
There's a block of code above which checks to see if the year of the current record is different than the last record, if so, it closes off the table row and inserts a row for the year heading. If you try it out with 16 records (combinations of each of the 4 years and 4 regions) you'll see what I mean.
http://localhost/nawc/campaigns_list.php
Oops - localhost. I do this all the time too. ;)
Chris
Re: [chris] getting individual record numbers?
By jimbly2 - December 7, 2009
http://www.madhouse1.com/clients/nawc/campaigns_list.php
that's what I meant to do
Jim
By Chris - December 7, 2009
Have you tried the code I gave you above? Let's see how close it gets to your layout.
Chris
Re: [chris] getting individual record numbers?
By jimbly2 - December 7, 2009
..yep I inserted the code below the existing table I created - at the bottom.
It breaks it into 4 columns but I'm not sure how to get it to match the styling?
best,
Jim
By Chris - December 7, 2009 - edited: December 7, 2009
I've simply chopped HTML out of your example table and spliced it into the new code, changes in red:
<table>
<tr>
<?php foreach ($resolutionsRecords as $record): ?>
<?php if ($record['year'] != @$currentYear): ?>
<?php if (@$currentYear): ?>
</tr><tr>
<?php endif ?>
<?php $currentYear = $record['year'] ?>
<?php $columnCount = 0 ?>
<td colspan="7"> </td>
</tr><tr>
<td width="17"> </td>
<td width="31" bgcolor="#99CCFF"> </td>
<td width="17" bgcolor="#DAFBFF"> </td>
<td colspan="4" bgcolor="#DAFBFF">
Resolutions passed at the <?php echo htmlspecialchars($currentYear) ?> Conference:
</td>
</tr><tr>
<?php endif ?>
<?php $columnCount++ ?>
<td colspan="3"> </td>
<td align="left" valign="top" <?php echo $columnCount % 2 ? 'bgcolor="#FFFFCC"' : '' ?>"><p><span class="heads_campaign">Region <?php echo $record['region'] ?></span><br />
<span class="bodytext_indent"><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></span></p>
<p> </p>
<p> </p>
<p> </p>
</td>
<?php endforeach ?>
</tr>
</table>
I hope this helps! Please let me know if you have any questions.
Chris
Re: [chris] getting individual record numbers?
By jimbly2 - December 8, 2009
thanks for that - it's sooo close! I can't quite work out why thte first row is wrapping round - rather than going the whole width of the table?
Also - can the cell widths be fixed to be equal?
thanks for all your help,
Jim
By ross - December 8, 2009
I had a look and I think the problem is going to be related to this line:
<td colspan="4" bgcolor="#DAFBFF">Resolutions passed at the 2008Conference:</td>
That colspan will need to be much higher. Try colspan="18". That will get it stretching all the way across.
Let me know what you think :).
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/