====== Randomly Generated Officers ====== // 11 work out how many applicants. $apps = rand (20,60); // set up some arrays as lookups for the values from the d10 rolls $prev = array ("Pilot", "Astronaut", "Pacifier Pilot", "Command", "Astronaut", "Technical", "Legal", "Medical", "Logistics", "Marine"); $crim = array ("Colonial Fleet", "Battle Fleet", "Fleet Support", "Naval Staff", "Training", "Port Staff", "Special Duties", "Shipyard", "Naval Staff", "Naval Academy", "Command", "Command", "Admiralty", "Command"); $refs = array ("Poor", "Guarded", "Guarded", "Guarded", "Average", "Good", "Good", "Good", "Excellent", "Excellent"); $Ranks = array ("Ensign", "Lieutenant", "Lt.Commander", "Commander", "Captain", "Flag Captain", "Rear Admiral", "Vice Admiral", "Admiral of the White", "Admiral of the Black","Grand Admiral"); // set up a table inside a form so that the chosen applicants can be taken forwards to the next stage. echo "

Applicant Details

\n \n
\n \n "; $appl=1; $rank=0; // for each applicant then roll the various dice and then set the variables do { $CrimCheck=rand(0,9); $Experience=rand(0,9); $RefCheck=rand(0,9); $Gender=rand(0,8); $BirthGender=$Gender; $GenderChanged="No"; if($Gender==0) { $GenderChanged="Yes"; $BirthGender=rand(1,8); $Gender=rand(1,8); } if($Gender==9) { $BirthGender=rand(1,8); $gend="Cyborg"; } if($Gender<5) { $sex="M"; $gend="M"; } elseif($Gender<9) { $sex="F"; $gend="F"; } elseif($BirthGender<5) { $sex="M"; $gend="M"; } else { $sex="F"; $gend="F"; } $Homeworld="Earth, Q0"; $gen=rand(0,9); if($gen > 2) { // set the necessary connection variables to connect to MySQL include ("/var/www/html/INI/sqlconnect.php"); // connect to MySQL server and select the INI database include ("/var/www/html/INI/sqlconnect2.php"); $db1 = mysql_select_db('full-moon_info_-_INI',$connection); // randomly select a system from the database $sql1 = 'SELECT * FROM `stardata` where control = "EE" ORDER BY Rand() LIMIT 5'; $homes = mysql_query($sql1); while ($row1=mysql_fetch_array($homes,MYSQL_ASSOC)) { end($row1); extract($row1); $Homeworld = "$StarName, Q$Quadrant"; } } // set the necessary connection variables to connect to MySQL include ("/var/www/html/IFU/sqlconnect.php"); // 21 connect to MySQL server and select the IFU database include ("/var/www/html/IFU/sqlconnect2.php"); $db = mysql_select_db('full-moon_info_-_IFU',$connection); // randomly select a group of names from the database $sql = 'SELECT * FROM `Names` ORDER BY Rand() LIMIT 10'; $names = mysql_query($sql); // step through the selected list of names to get a surname and forename from separate rows while ($row=mysql_fetch_array($names,MYSQL_ASSOC)) { extract($row); $LastName = $Surname; next($row); // then randomly take a firstname of the correct gender from the same list if ($Gender==$sex) { $Forename = $FirstName; next($row); extract($row); end($row); } } // $Surnames = mysql_query($sql2); // $Surname = $Surnames["Surname"]; // $sql2 = 'SELECT * FROM `Names` WHERE Gender=$sex ORDER BY Rand() LIMIT 2'; // $FirstName = $names["FirstName"]; $last4 = $appl + rand (1000,9799); $promote = $promote + 1 + $rank + rand (0,6); if ($promote>35) {$rank++; $promote=0;} $PQ = $Quadrant; $move = rand (0,10); if ($move>7) { if($PQ==0) {$PQ=rand(0,8);} if($PQ>0) {$PQ = rand(0,1) * rand (0,8);} } echo " \n "; $appl++; } while ($appl<=$apps); echo "
Last 4 \n Current Rank \n Firstname \n Surname \n Branch \n Current Location \n New Posting \n
$last4 \n $Ranks[$rank] \n $Forename \n $LastName \n $prev[$Experience] \n $Homeworld \n $crim[$CrimCheck], Q$PQ \n
"; echo "
";