![]() |
Getflight page... - Printable Version +- FsPassengers Forums (http://www.fspassengers.com/forum) +-- Forum: FsPassengers (http://www.fspassengers.com/forum/forumdisplay.php?fid=3) +--- Forum: FsPassengers Customizing (http://www.fspassengers.com/forum/forumdisplay.php?fid=6) +--- Thread: Getflight page... (/showthread.php?tid=10120) |
Getflight page... - Vegas_09 - 03-05-2006 Hi, Was wondering if any good programmer could help me? In the database that holds my flights I also have a "user" table. This table holds login info for others, thier FSP rank and some other data. What I would like to do is when a flight is exported is to also insert the pilots rank to the newly exported flight. Which is to say the script has to also connect to the "user" table, pull the rank for the "PilotName" that is exporting the flight and update all entries with that Pilots name. (Update thier rank) This is what I have added to the GetFlight page: $Name = $_REQUEST['PilotName']; $connection = mysql_connect ("localhost", "login", "pass"); $query="SELECT * FROM user WHERE CallSign='$Name'"; $result = mysql_db_query ("database", $query); $Rank = $row["FSPRank"]; $connection = mysql_connect ("localhost", "login", "pass"); $query="SELECT * FROM flights WHERE PilotName='$Name'"; $result = mysql_db_query ("database", $query); $sql = mysql_query("UPDATE flights SET FSPRank='$Rank' WHERE PilotName='$Name'"); It is not working!! ![]() Re: Getflight page... - DBE - 04-05-2006 Hey Wayne, Sorry, but this is a rather more complex issue than you suspect. The dataset which is exported by FsP is hardcoded. This means that only those fields can be used in your PIREP. If you have access to the MySQL tables of your database, take a look and you will see that there actually a couple of fields which are currently not included in the default script; unfortunately rank info is not one of them. ![]() Re: Getflight page... - Vegas_09 - 04-05-2006 I know. I have added the field for the rank. Now all I need to do is when a flight is exported is to have the script also connect to the "User" table and extract the rank for that pilot name and update all entries in the flights table. It should work with the code I have pasted above but doesnt. Re: Getflight page... - eazy - 04-05-2006 Hmm, so how do you get the FSPRank value into the user db? I suppose you've added this field too. Is it a manual input by your pilots? And what happens if you run the script? Is there an error msg or just nothing happening? Re: Getflight page... - Vegas_09 - 04-05-2006 Yes it has been added, and yes they manually input thier rank. I have set it up so when they attempt to update thier rank it checks to see if they have enough flight hours for the rank they are trying to update to. If not, they get an error message. I cannot put a control measure on if they do not have enough points. ![]() script that allows us to export pilot stats!! When I attemp to export a flight everything works fine, except the rank for the pilot that exports the flight reflects the default value, which is student pilot, instead of connecting to the user database, identifying the rank for the pilot that is exporting the flight, and updating all entries. Agian this is the code I have added to the Getflight page: $Name = $_REQUEST['PilotName']; $connection = mysql_connect ("localhost", "login", "pass"); $query="SELECT * FROM user WHERE CallSign='$Name'"; $result = mysql_db_query ("database", $query); $Rank = $row["FSPRank"]; $connection = mysql_connect ("localhost", "login", "pass"); $query="SELECT * FROM flights WHERE PilotName='$Name'"; $result = mysql_db_query ("database", $query); $sql = mysql_query("UPDATE flights SET FSPRank='$Rank' WHERE PilotName='$Name'); Re: Getflight page... - crowebird - 04-05-2006 you could always follow dans rulings and php all if it... so if they dont upload a flight they wont get those hours credited towards their rank... what I mean is you can get all the hours flown from one pilot, and how many bonus/penalty points they have, and then have a preset list so if hours is > (this many hours needed for C#) and total points > (total points needed for the C#).. I see you have already pretty much done this, but make it all automatic, which will also be a better reason for your pilots to upload flights every time they fly Re: Getflight page... - eazy - 05-05-2006 Wayne, as far as I can see, the problem is the array $row[] which isn't assigned anywhere in your script. $result = ... gives you the subset of the sql query but not the array of data fields yet. Try this: $Name = $_REQUEST['PilotName']; $connection = mysql_connect('localhost', 'login', 'pass'); if (mysql_select_db('database',$connection)) { $query = "SELECT FSPRank FROM user WHERE CallSign='$Name' "; if ($result = mysql_query($query)) { $row = mysql_fetch_row($result); $Rank = $row['FSPRank']; mysql_query("UPDATE flights SET FSPRank='$Rank' WHERE PilotName='$Name' " ); } } Hope it works, I didn't test it. (there are some unnecessary blanks to avoid forum smilies ![]() btw: the function mysql_db_query is a little outdated with PHP4 and 5. Re: Getflight page... - Vegas_09 - 07-05-2006 Nope, that didnt work either. I have a fix for now. I just wrote a script that updates the rank on the flights page from the user table everytime the list flight page is run. Just added an "include". The page still runs fast and works well! Quick fix for now ![]() Is there a way to run a page every hour or so on a server without actually go to that page? I am not very familer with cron jobs. Post Edited ( 05-07-06 11:50 ) Re: Getflight page... - olseric - 11-05-2006 Not a PHP guy, but a Perl guy here... Just a question...if it is an array, does PHP use an @ sign for it like in Perl? (i.e. @array = some array, $scalar = some scalar). |