Jump to content

flynryan692

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by flynryan692

  1. I will give this a shot and see what happens. Thank you!
  2. Thank you (sorry for the late reply, I got busy with some other stuff). If I am understanding this correctly I should query all callsigns, which could be thousands in certain cases, and use it as the key of the array and the number the callsign was used as the value. I'm a bit confused as to how this works. Currently, the query is using a substr on each callsign so it only has the first three characters, but I no longer want it to function that way. Maybe I need to make a better example.. So lets say in a database I have the following flights: SWA1545, DAL1755, TANKR11, SWA388, N5439K, G-CHRE, N334R, DAL355, SWA2115 Now what I'd like to do is determine what airline each flight it is and count up how many times it was used. Each airline flight, such as the SWA ones, should only give me the characters SWA, the TANKR11 callsign should return TANKR, and the N5439K should return only N (I've sort of got this bit written already in my OP where it takes the variable $Airline and determines the code to use). Now I want to take the code and use it in a link to an image that is inside an HTML table, which is easy. Next I want to count of each instance of a callsign, which will go to the right of the image. So, how many times was SWA used? How many times was N used? TANKR? etc and echo this inside an HTML table. The table rows are included in my OP to show how it is being used currently. Thank you for the help!
  3. Hello, I am working on an aviation website and on a part of my site I want it to display information regarding a pilot log book. Currently I just query all the flights for a member and use substr to get the first three digits (typically an ICAO code) then run it past a few IF's so that if there is a private registration (like N612ER, G-PCH, A6-EDG etc) I can get the right character (N, G, or A6) and then I use the character to display an image. It counts how many times each three character group is used. So lets say a member has 15 Air Canada flights (ACA), 5 Southwest flight (SWA), 3 British Airways (BAW), and 2 flights under N622ER (N62) it will display the logo for each airline, or a "private registration" image for each country after is runs pasts the IF's and turns "N62" into "N". What I would like to do is expand the capability of this so that it will count how many times the characters were used. Right now if they have three different American private registrations it displays them separately because they are actually N62 or N54, I want to group it so that all American registrations are together, British together etc. I also want to be able to support military call signs, so something like EAGLE13 (I want the word EAGLE) which my IF's that check the characters will do. So, tl;dr if I change my query to get all the members callsigns how would I then count up each instance of an airline, private registration, or military call sign and display the top 5, highest to lowest as I do now? Here is what the code I want to change currently looks like... <?php $sql = "SELECT COUNT(*) AS Nr, SUBSTR(Callsign, 1, 3) as Airline FROM {$dbprefix}Reports WHERE PilotID=$userid GROUP BY Airline ORDER BY Nr DESC LIMIT 5"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $nr = $row["Nr"]; $airline = $row["Airline"]; if ($airline[2] == '-'){//is the 3rd char a hyphen? $icao = substr($airline,0,2); }elseif ($airline[1] == '-'){//is the 2nd char a hyphen? $icao = substr($airline,0,1); }elseif (is_numeric($airline[1])){//is the 2nd char a number? $icao = substr($airline,0,1); }else{ $re1='((?:[a-z][a-z]+))'; //search term for a word? if ($c=preg_match_all ("/".$re1."/is", $airline, $matches)){ $icao=$matches[1][0]; //1st occurance } } $pathtofile = ($_SERVER['DOCUMENT_ROOT'] . "/cms/images/airlines/$icao.jpg"); $exists = file_exists($pathtofile); if (file_exists($pathtofile)) echo "<tr><th class=\"profile3\"><img src=\"http://www.website.org/cms/images/airlines/$icao.jpg\" /></th><td class=\"profile2\">$nr</td></tr>"; else echo "<tr><th class=\"profile3\">$airline</th><td class=\"profile2\">$nr</td></tr>"; } ?>
  4. That did it, thank you! I didn't think it would be as simple as single quotes vs double quotes.
  5. Here is what I am trying to do, I want to take the first three letters of a flight number known as the ICAO code from my database and then check if the logo of the airline exists in my folder full of images. If the image exists I want to display it next to my other information, if it does not I want to simply write "Unknown". Here is what I have $callsign = $row["Callsign"]; $icao = substr($callsign, 0, 3); $pathtofile = ($_SERVER['DOCUMENT_ROOT'] . '/cms/images/airlines/$icao.jpg'); $exists = file_exists($pathtofile); Then I have the following to display the image <?php if ($exists) { ?> <tr><td><?php echo $txt["airline"] ?>:</td><td></td><td><img src="http://www.mysiteurl.org/cms/images/airlines/<?php echo $icao ?>.jpg" /></td></tr> <?php } else { ?> <tr><td><?php echo $txt["airline"] ?>:</td><td></td><td>Unknown</td></tr> <?php } ?> For some reason it keeps showing up as "Unknown" meaning the image doesn't exist, when I know it does. If I simply use echo $pathtofile the image shows up, but when I use $exists or even if file_exists($pathtofile) it keeps telling me the file does not exist. Here is the the odd part, if I replace $icao in $pathofile with the an airline code then it works, which leads me to believe something could be wrong with $pathofile Any ideas? Thanks
  6. This should be simple, I think I am just confusing my self... Ok, so I have a navigation bar at the top.. <div id="nav"> <ul> <li><a href="?page=index"></a></li> <li><a href="?page=blah"></a></li> <li><a href="?page=cool"></a></li> <ul> </div> Ok, so I want to say, if the person is on the "cool" page then <a href=?page=cool class="active" > else <a href=?page=cool > How would I do that efficiently for every single link? Also, I have a drop down, and a submenu in the drop down...aagh. I can post the entire nav bar if needed..
  7. That looks right I'll give it a try and let you know how it worked out.
  8. Well, I have figured this much out..however it is showing the same amount for each person and for some reason it isn't adding either... Any ideas? $plink = mysql_query("SELECT sum( dur ) as H FROM pireps WHERE login='$glogin' AND status='1' ") or die("MySQL Said:".mysql_error()); $presult = mysql_fetch_assoc($plink); $dur = $presult['H']; $hlink = mysql_query("SELECT ( thours ) as HR FROM `pilots` WHERE status = '1' AND hub='$phub' ")or die(mysql_error()); $hresult = mysql_fetch_assoc($hlink); $hours = $hresult['HR']; $test = $dur + $hours;
  9. Ok, so..I think I may sorta know how to do this..but I am unsure...I'm a n00b at php :/ So, on my site when the person joins then can transfer hours which is called thours in mysql. Then, as a member they fill out a report will all the details blah blah great. Well, so far it all works, however I want it so when a person looks at the roster is displays the transfer hours but then adds up all the hours from each report. So, I guess what I am asking is how would I write it so that is gathers up the duration (dur in mysql) from each report and adds it to thours for each person. I'll post the code from the page called hub. I want to add $dur (on the pirep page) with thours on the hub page... I hope me posting this code doesn't make it super long and annoying..I'm just unsure of how much of the code will be needed so you guys know what to do to help...this code is the hub page. <? if($hub==''){echo'No Hub Slected';}elseif($hub == 'KLAX'){?><style type="text/css"> <? } ?> <? if ($_GET[sort]){ $sort = $_GET[sort]; } else { $sort = "login $view"; } if ($_GET[view]){ $view = $_GET[view]; } else { $view = "ASC"; } if ($view == "ASC"){ $newview = "DESC"; } elseif ($view == "DESC"){ $newview = "ASC"; } else { $view = "DESC"; } if ($_GET[hub]){ $hub = "hub='$_GET[hub]' AND"; } else { $hub = ""; } if ($sort == "login"){ $mlist = mysql_query("SELECT * FROM `pilots` WHERE status = '1' AND hub='$hub' ORDER BY login $view") or die(mysql_error()); } else { $mlist = mysql_query("SELECT * FROM `pilots` WHERE status = '1' AND hub='$phub' ORDER BY $sort $view")or die(mysql_error()); } $mlrows = mysql_num_rows($mlist); $hubstaff = mysql_query( "SELECT * FROM `pilots` WHERE hm = '1' AND hub = '$phub' LIMIT 1" ) or die("MySQL Said:".mysql_error()); $hubs_num = mysql_num_rows($hubstaff); if($hubs_num == 0){echo'<table widith=100%>No hub manager selected for this hub currently</table>'; } elseif ($hubs_num == '1'){ $hubr = mysql_fetch_assoc($hubstaff); $fname = $hubr["fname"]; $lname = $hubr["lname"]; $hlogin = $hubr["login"]; $hemail = $hubr["semail"]; echo"San Jose Operations Manager: $hlogin $fname $lname<br /> Email : $hemail"; } ?> <table width=100% cellspacing=0> <? if($mlrows == 0){ echo'No Pilots in this hub'; } else { echo" <tr bgcolor=#034e75> <td colspan=7 align=center><div align=center><span class=style1><font color=white>SnapJet $phub Pilot Roster</font></span></div></td> </tR> <tr bgcolor=#EEEEEE align=center> <td><a href=#>Login</font></a></td> <td><a href=#>First Name</a></font></td> <td><a href=#>Last Name</font></a></td> <td><a href=#>Rating</font></a></td> <td><a href=#>Hours</font></a></td> </tr> <br /><br /> "; while ($alr = mysql_fetch_array($mlist)){ $counter = $counter + 1; if ($counter % 1 == 0){ $bgcolor = "#FFFFFF"; } if ($counter % 2 == 0){ $bgcolor = "#EEEEEE"; } ?> </tr> <tr align=center bgcolor=<? echo"$bgcolor";?>> <td width=10%><a href="?page=profile&login=<? echo"$alr[login]";?>"><? echo"$alr[login]";?></a></td> <td width=15%><? echo "$alr[fname]"; ?></td> <td width=15%><? echo "$alr[lname]"; ?></td> <td width=15%><? echo "$alr[rating]"; ?></td> <td width=10%><? echo "$alr[thours]"; ?></td> <? }} ?> </table> <br /> <center> </center>
  10. Hello, I'm trying to make it so if they are logged in or out it shows a certian php file...its not working..any ideas? Sorry if this is an easy question..I'm still learning. Here is what I have. <?php if(!session_is_registered('callsign') AND !session_is_registered('password') AND !session_is_registered('email') AND !session_is_registered('name') ){ echo (include 'content/side.php'); } else { echo (include 'content/pilots.php'); } ?>
  11. Thanks for the reply, here is the entire script for that part. <? if ($from == ''){ echo '<option value="">Please Select a City or Airport</option>'; } ?> <?php do { ?> <? if ($from == ''){ echo '<option value="?from='.$row_dep['dep_icao'].'&#to">'.$row_dep['dep_city'].'</option>'; } else { echo '<option value="?from='.$row_dep['dep_icao'].'&#to">'.$row_dep['dep_city'].'</option>'; } ?>
  12. I'm a bit of a n00b and the script I'm using is not 100% mine. It looks for stuff, like a booking script. When I pick a city the url changes from ?page=flights to ?from=Atlanta&#to "to" being the destination city. Well my site has a get statement on the index as you can see so ?page=flights is in the content folder as flights.php. I know in order for this to work it should say flights.php?from=Atlanta&#to in order to work, how would I change the get function in the script to work? Below is the get function in the script (i think thats it).. <? if ($from == ''){
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.