Moderators servetas Posted June 6, 2012 Moderators Report Share Posted June 6, 2012 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 Quote Link to comment Share on other sites More sharing options...
Tom Posted June 6, 2012 Report Share Posted June 6, 2012 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++; } Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted June 6, 2012 Author Moderators Report Share Posted June 6, 2012 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> Quote Link to comment Share on other sites More sharing options...
Tom Posted June 6, 2012 Report Share Posted June 6, 2012 Well it does if you learn from it rather than try to just apply it directly... I don't know how you've coded it. Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted June 6, 2012 Author Moderators Report Share Posted June 6, 2012 If you do not like the way i am coding, you can just ignore my posts . Thank you for your help... Quote Link to comment Share on other sites More sharing options...
Vidofnir Posted June 15, 2012 Report Share Posted June 15, 2012 <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. Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted June 30, 2012 Author Moderators Report Share Posted June 30, 2012 Does not work. It always shows 1. Quote Link to comment Share on other sites More sharing options...
dimitris Posted June 30, 2012 Report Share Posted June 30, 2012 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 Quote Link to comment Share on other sites More sharing options...
Strider Posted July 1, 2012 Report Share Posted July 1, 2012 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. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.