# Need Some Code Help Please

**URL:** <https://forum.phpvms.net/t/need-some-code-help-please/3980>\
**Category:** phpVMS Legacy Support (v2/v5)\
**Created:** [January 31, 2011, 9:29pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980 "2011-01-31T21:29:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [January 31, 2011, 9:29pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/1 "2011-01-31T21:29:01Z")

</div>

Ok guys. It is once again time for me to make my self look real stupid which I am pretty good at doing.

All I am trying to do is insert a pilots ID and First and last name in a table. The Pilot ID should be a link to his or her own public profile while the first and last name are merely that, just a name (no link).

I have tried every single code I can until I have been blue in the face for 4 or 5 days now and still no good. I simply can not figure out how to get that code or where it comes from. I have consulted many php readings and all of it is different then we use here it seems.

So I figure after almost a week of trying it was time to ask. I hate to ask for help 5 minutes in to having a problem. I prefer to try to help my self, but this time I fell short in my quest. Any help would be gladly accepted and very much appreciated at the same time.

Ray

---

<div class="post-metadata">

**Author:** ![Kyle](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@Kyle](https://forum.phpvms.net/u/Kyle)\
**Post date:** [January 31, 2011, 9:45pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/2 "2011-01-31T21:45:03Z")

</div>

Something like that…

```
<a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
  <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>

```

So, Compelete your request…

```
<a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
  <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>

<?php echo $pilot->firstname.' '.$pilot->lastname?>

```

That’s it!!

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 1, 2011, 5:51pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/3 "2011-02-01T17:51:50Z")

</div>

Hi Vansers. Let me try that and see how it goes. Maybe I had a typo when I tried it but that looks exactly like I tried it from day one. I will come back and let you know how it goes. Thanks a bunch!

Ray

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 1, 2011, 5:56pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/4 "2011-02-01T17:56:48Z")

</div>

That returns 0000 as the pilot ID and nothing for the name. Do I need to add a foreach() or something somewhere maybe?

At one point in time I did have it producing what I wanted, except when clicking the ID number it went to a page that said Pilot Does Not Exist. If I can get it to reproduce that I will and let you know what code I used.

---

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [February 1, 2011, 6:48pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/5 "2011-02-01T18:48:00Z")

</div>

OK you need to get the data, use,

```
<?php echo $pilot->firstname.' '.$pilot->lastname ?> <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?>

```

Self explanatory then you can use as you wish and put in the link

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 1, 2011, 7:14pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/6 "2011-02-01T19:14:08Z")

</div>

Thanks. I really do appreciate it. As I said this one has been aching my back side for days now. Maybe one of these years I will get this phpVMS code figured out.

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 1, 2011, 7:21pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/7 "2011-02-01T19:21:45Z")

</div>

Well I am not sure exactly what is going on or why. I used the code and got the same results again. lol Pilod ID 0000 and Nothing for the name.

Here is what I got so far.

```
<div class="sidearea2">
       <h2>Newest Pilots:</h2>
       <div class="box3">
	<table>
       <thead>
    <tr>
      <th width="50%" scope="col">Pilot ID#</th>
      <th width="50%" scope="col">Name</th>
    </tr>
   </thead>
 <tbody>
  <tr>
     <td><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
    <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
  </td>
   <td><?php echo $pilot->firstname.' '.$pilot->lastname ?>
    </td>
  </tr>
 </tbody>
</table>
</div>
</div>

```

Maybe this topic should get moved to Skinning. I never thought of posting there to begin with. Blonde moment at it’s finest I guess.

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 4, 2011, 12:09am UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/8 "2011-02-04T00:09:26Z")

</div>

Kind bump.

Anyone?

---

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [February 4, 2011, 12:20am UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/9 "2011-02-04T00:20:53Z")

</div>

Maybe you can mash this up to get what you want, this will run outside vms, should also work inside with a bit of alteration.

```
<?php
error_reporting(E_ALL);
include '/YOURPATH TO CORE//core/codon.config.php';
$allpilots = PilotData::getAllPilots();
foreach($allpilots as $pilot)
{
}
?>
<h3>Aerosoft Pilot Hours Validation</h3>
<p>To Quick search name or pilot id hit Ctrl + F and and type in data.</p>
<?php

  if(!$allpilots)

  {

     echo 'There are no pilots!</div>';

     return;

  }

?>

<table width="380" cellspacing="1" cellpadding="5" border="1">
 <thead>
   <tr>
     <th width="60px">Pilot ID</th>
     <th width="200px">Name</th>
     <th width="55px">Hours</th>
     <th width="65px">Active/Inactive</th>
   </tr>
 </thead>

<tbody>

<?php

foreach($allpilots as $pilot)

{

  /* 

     To include a custom field, use the following example:

     <td>

        <?php echo PilotData::GetFieldValue($pilot->pilotid, 'VATSIM ID'); ?>

     </td>

     For instance, if you added a field called "IVAO Callsign":

        echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign');

   */

?>

<tr>

  <td width="1%" nowrap><a href="<?php echo SITE_URL?>/index.php/profile/view/<?php echo $pilot->pilotid?>">

        <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>

  </td>

  <td>

     <div align="left"><img src="<?php echo Countries::getCountryImage($pilot->location);?>" 

        alt="<?php echo Countries::getCountryName($pilot->location);?>" />
<?php echo $pilot->firstname.' '.$pilot->lastname?>
        </div></td>
  <td><div align="center"><?php echo $pilot->totalhours?></div></td>
<td><div align="center"><?php
   If ($pilot->retired == 0)
         { echo '<img src="/images/green-status.gif" />'; }
   else
         { echo '<img src="/images/red-status.gif" />'; }
?></div></td></div></td>
<?php

}

?>
</div>
</tbody>
</table>

```

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 4, 2011, 2:11am UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/10 "2011-02-04T02:11:09Z")

</div>

I’ll see what I can cook up with that. Thanks a bunch!

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 4, 2011, 2:25am UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/11 "2011-02-04T02:25:47Z")

</div>

I had to doctor up the code but by gumpus she works now! Now my only issue is, it is only putting one pilot in the table and dropping the rest out of the table.

I wonder if I need to move my

```
<?php

}

?>

```

or something. I have never had an issue with a table doing that before to be honest.

\*\*EDIT\*\*

That was it. I had to move that little ditty of code up inside of the table. Once I did that, everything fell in to place.

Thanks for helping me out. I REALLY appreciate it! I did everything for the past week I could think of to do. And yeah it all boiled down to me not having the for each and closing php in the code. Oops!

---

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [February 4, 2011, 8:09am UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/12 "2011-02-04T08:09:36Z")

</div>

Good job, i know what its like banging your head and i also know what its like when you get things working

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 4, 2011, 9:52pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/13 "2011-02-04T21:52:46Z")

</div>

Yeah it was rough. And great when I finally nipped and tucked the code you offered and it worked.

Long story short, I had it right once. It was out putting data, it was just wrong. I then ditched my code in a effort to make it right. That was the wrong move. Once I saw the code you posted, I knew when I used the for each the first time I was on track.

I really do thank you for the help though. I normally never try to ask for help until it is the last resort. I try to help myself first. Many times people come here looking for help before they even try to help them selves.

Ray

---

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [February 5, 2011, 12:09am UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/14 "2011-02-05T00:09:23Z")

</div>

Hey no problem Ray were all there at times

After all i have learnt so much here on this site and coding other options in phpVMS.

Great support here all round.

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 16, 2011, 6:07pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/15 "2011-02-16T18:07:33Z")

</div>

Ok 1 last thing on this one. After looking at and admiring the table that finally works with help from other peers here, I have decided that the black text for the status has got to be changed to red or green depending on the status of the pirep. The million dollar question is do I shade the whole background of the status or just change the text color?

Is this done via the CSS file? Or is it hard coded in the tpl file? I have tried a couple different ideas and came up with errors. I know this is so simple I am gonna smack myself int he face when I find the answer or someone graciously offers it up.

---

<div class="post-metadata">

**Author:** ![nabeel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/nabeel/32/2971_2.png) [@nabeel](https://forum.phpvms.net/u/nabeel)\
**Post date:** [February 16, 2011, 8:22pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/16 "2011-02-16T20:22:52Z")

</div>

I like to use CSS class names for that, using Jeff’s example:

```
if($pirep->accepted == PIREP_REJECTED) {
$text = 'REJECTED';
$class =' pirep-rejected';
} elseif($pirep->accepted == PIREP_PENDING) {
$text = 'PENDING';
$class =' pirep-pending';
} else {
$text = 'ACCEPTED';
$class =' pirep-accepted';
}

echo "<span class='{$class}'>{$text}</span>";

```

Then the CSS:

```
span.pirep-accepted { color: #00ff00; }
span.pirep-rejected { color: ....; }
span.pirep-pending { color: ...; }

```

Either way works

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 16, 2011, 8:39pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/17 "2011-02-16T20:39:02Z")

</div>

Thanks guys! I really appreciate it. I was right on both counts then I was just doing it wrong. Thanks again and I will once again mark this one solved.

---

<div class="post-metadata">

**Author:** ![nabeel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/nabeel/32/2971_2.png) [@nabeel](https://forum.phpvms.net/u/nabeel)\
**Post date:** [February 16, 2011, 9:31pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/18 "2011-02-16T21:31:21Z")

</div>

> I have used that also. I think that I have done it about 10 different ways. Someday have to go back and organize them all into one way.

Haha yeah, whatever style works for you

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [February 16, 2011, 10:19pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/19 "2011-02-16T22:19:57Z")

</div>

That is my situation to Lorathon. I do the same thing so many ways I loose track of the way it should have been done then never go back and organize.

Maybe one of these days I will get my head on straight and fix it all. My code on my files is just plain old messy at it’s finest.

---

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [February 16, 2011, 10:38pm UTC](https://forum.phpvms.net/t/need-some-code-help-please/3980/20 "2011-02-16T22:38:18Z")

</div>

Yes i agree, there are so many modifications that i have made in so many different ways that work that to standardize it I would be working trough all the tpl’s for a month.

I know as my knowledge grows with phpVMS so does the coding standards i implement, I have learnt so much since being involved with this community not only just with phpVMS but with php as well.

Believe me i knew nothing! and still dont

I went to school when computers just didnt exist, all we had was the BBC computer if i remember rightly, i still kick myself for not pushing myself to learn a code php, javascript.

Google is now my best friend

[Next page](https://forum.phpvms.net/t/need-some-code-help-please/3980.md?page=2)
