Jump to content

Course the tr od a table


servetas

Recommended Posts

  • Moderators

Hello everyone,

i am trying to built my own award module for my virtual airline in order to have the possibility to add the same award multiple times to a pilot. For now i have stucked on a "silly" part:

I want to make an auto count the <tr> of my table awards. Fore example:

Auto Number Award Type Issued

1. Good Pilot 10/10/10

2. Good Landing 11/10/12

I just want to create the bold numbers automatically ;).

servetas

Link to comment
Share on other sites

  • Moderators

This does not help because i have built me .tpl file like this:


<p class="under_blue">
<?php
$id = $awardname->awardid; ?>
<?php
$awardid = AwardData::get_award_tittle_by_id($id);  ?>
<?php
echo $awardid->name;
?></p>
<table width="70%" border="0">
<tr>
<td width="60%">Comment</td>
<td width="20%">Date</td>
</tr>
<?php
if(!$awardinfo)
		{echo '<tr><td><center>There are no any awards issued!</center></td></tr>';}
		else
		{
foreach($awardinfo as $info)
{ ?>
<tr>
<td><?php echo $info->comment; ?></td>
<td><?php echo $info->dateissued; ?></td>
</tr>
<?php } } ?>
</table>

Link to comment
Share on other sites

  • 2 weeks later...

<p class="under_blue">
<?php
$id = $awardname->awardid;
$awardid = AwardData::get_award_tittle_by_id($id);
echo $awardid->name;
?>
</p>

<table width="70%" border="0">
<tr>
<td width="60%">Comment</td>
<td width="20%">Date</td>
</tr>
<?php
if(!$awardinfo)
{
echo '<tr><td><center>There are no any awards issued!</center></td></tr>';
}
else
{
$count = 1;

foreach($awardinfo as $info)
{ ?>
<tr>
<td><?php echo $count . ". " . $info->comment; ?></td>
<td><?php echo $info->dateissued; ?></td>
</tr>
<?php
$count++;
}
} ?>
</table>

That should work.

Link to comment
Share on other sites

  • 2 weeks later...

George and Vidofnir,

Vidofnir's code is okay but there is a small mistake which cause the problem the $count++; should be inside the table row so this is the correct way to do it:

<p class="under_blue">
<?php
$id = $awardname->awardid;
$awardid = AwardData::get_award_tittle_by_id($id);
echo $awardid->name;
?>
</p>
<table width="70%" border="0">
<tr>
<td width="60%">Comment</td>
<td width="20%">Date</td>
</tr>
<?php
if(!$awardinfo)
{
echo '<tr><td><center>There are no any awards issued!</center></td></tr>';
}
else
{
$count = 1;
foreach($awardinfo as $info)
{ ?>
<tr>
<td><?php echo $count;
$count++;
?>
<?php echo $info->comment; ?></td>
<td><?php echo $info->dateissued; ?></td>
</tr>
<?php
}
} ?>
</table>

PS:George it is corrected at our website by me :P

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...