Jump to content

Recommended Posts

  • Moderators
Posted

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

Posted

You'll probably be looping through your awards?

So you can do something like

$i=1;
while($award = mysql_fetch_array($my_awards)){
 echo '<td>'.$i.'</td>';
 // Do other things
 $i++;
}

  • Moderators
Posted

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>

  • 2 weeks later...
Posted

<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.

  • 2 weeks later...
Posted

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

Posted

If you do not like the way i am coding, you can just ignore my posts :). Thank you for your help...

You missunderstood what Tom said, he didn't say he didn't like the way you coded it, he said he didn't know how you coded it.

  • Like 1

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...