TAV1702 Posted January 31, 2011 Report Posted January 31, 2011 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 Quote
Moderators Kyle Posted January 31, 2011 Moderators Report Posted January 31, 2011 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!! Quote
TAV1702 Posted February 1, 2011 Author Report Posted February 1, 2011 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 Quote
TAV1702 Posted February 1, 2011 Author Report Posted February 1, 2011 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. Quote
Moderators mark1million Posted February 1, 2011 Moderators Report Posted February 1, 2011 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 Quote
TAV1702 Posted February 1, 2011 Author Report Posted February 1, 2011 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. Quote
TAV1702 Posted February 1, 2011 Author Report Posted February 1, 2011 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. Quote
Moderators mark1million Posted February 4, 2011 Moderators Report Posted February 4, 2011 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> Quote
TAV1702 Posted February 4, 2011 Author Report Posted February 4, 2011 I'll see what I can cook up with that. Thanks a bunch! Quote
TAV1702 Posted February 4, 2011 Author Report Posted February 4, 2011 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! Quote
Moderators mark1million Posted February 4, 2011 Moderators Report Posted February 4, 2011 Good job, i know what its like banging your head and i also know what its like when you get things working Quote
TAV1702 Posted February 4, 2011 Author Report Posted February 4, 2011 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 Quote
Moderators mark1million Posted February 5, 2011 Moderators Report Posted February 5, 2011 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. Quote
TAV1702 Posted February 16, 2011 Author Report Posted February 16, 2011 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. Quote
Guest lorathon Posted February 16, 2011 Report Posted February 16, 2011 Sometimes if I want to change text color depending on data I do something like this $pirepStatus = '<font color="#00ff00">ACCEPTED</font>; if($pirep->accepted == PIREP_REJECTED) $pirepStatus = '<font color="#0000ff">REJECTED</font>'; if($pirep->accepted == PIREP_PENDING) $pirepStatus = '<font color="#0000ff">PENDING</font>'; echo $pirepStatus; But I am sure there are many ways to do this. Quote
Administrators Nabeel Posted February 16, 2011 Administrators Report Posted February 16, 2011 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 Quote
TAV1702 Posted February 16, 2011 Author Report Posted February 16, 2011 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. Quote
Guest lorathon Posted February 16, 2011 Report Posted February 16, 2011 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. Quote
Administrators Nabeel Posted February 16, 2011 Administrators Report Posted February 16, 2011 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 Quote
TAV1702 Posted February 16, 2011 Author Report Posted February 16, 2011 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. Quote
Moderators mark1million Posted February 16, 2011 Moderators Report Posted February 16, 2011 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 Quote
TAV1702 Posted February 16, 2011 Author Report Posted February 16, 2011 I recall being in 5th grade a looong time ago and we had got a computer and everyone was silenced by the newness of such a thing. It was a PET http://computer.yourdictionary.com/pet-computer Quote
Moderators mark1million Posted February 16, 2011 Moderators Report Posted February 16, 2011 This was my bad boy at the time just came out, http://www.bbc.co.uk/news/technology-10951040 The BBC Computer, yeh right massive 32k of memory How times change. Quote
TAV1702 Posted February 17, 2011 Author Report Posted February 17, 2011 Man we need to quit showing our age. lol I am not old but creeping up there quickly Quote
Administrators Nabeel Posted February 17, 2011 Administrators Report Posted February 17, 2011 Haha, my first computer was a 486, kinda crazy that my cellphone is much more powerful Quote
TAV1702 Posted February 17, 2011 Author Report Posted February 17, 2011 A friend of mine brought his sisters Dell ( oh now I feel sick ) over here for me to fix for her and I laughed and he asked me what was that is exactly what I pointed out to him Nabeel. Our phones now are more powerful then that PC he brought here is. He was like yeah I don't doubt it. I was like yeah there can be no doubt to it. It is hard core fact. Quote
TAV1702 Posted February 18, 2011 Author Report Posted February 18, 2011 Houston, we have a problem! Using this code below <?php if(count($pireps) > 0) { foreach ($pireps as $pirep) { $pilotinfo = PilotData::getPilotData($pirep->pilotid); $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid); if($pirep->accepted == '0') $status = '<font color="#0000ff">PENDING</font>'; if($pirep->accepted == '1') $status = '<font color="#00ff00">APPROVED</font>'; else $status = '<font color="#FF0000">REJECTED</font>'; echo '<tr>'; echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>'; echo '<td>'.$pirep->depicao.'</td>'; echo '<td>'.$pirep->arricao.'</td>'; echo '<td>'.$pirep->flighttime.'</td>'; echo '<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>'; echo '<td>'.$status.'</td>'; echo '</tr>'; } } else { echo '<tr><td>There are no recent flights!</td></tr>'; } ?> When a PIREP is submitted it should say pending. For one reason or the other, it is being marked as rejected. If I go in to the admin panel and approve it, it gets marked approved. I can not get it to mark a flight as pending. Thoughts? Concerns? Ideas? Thanks in advance. Ray P.S. This is not all the code that I use for this table. This is just the problem child of it all. I am sure it is simple fix and right under my nose. Quote
Guest lorathon Posted February 18, 2011 Report Posted February 18, 2011 Change to if($pirep->accepted == '0') $status = '<font color="#0000ff">PENDING</font>'; elseif($pirep->accepted == '1') $status = '<font color="#00ff00">APPROVED</font>'; else $status = '<font color="#FF0000">REJECTED</font>'; And it should work Quote
TAV1702 Posted February 19, 2011 Author Report Posted February 19, 2011 Ok I'll give that a try and see what happens. Thanks! Quote
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.