IEN Officers - generation // work out how many officers to promote. $Ensigns = rand(1,20); $Lts = $Ensigns + rand(1,10); $LtCdrs = $Lts + rand (0,10); $Cdrs = $LtCdrs + rand (0,8); $Capts = $Cdrs + rand (0,4); $RAdms = $Capts + rand (0,1); $apps = rand (6,200); $no = 590000; // set up some arrays as lookups for the values from the d10 rolls $Branch=array("Pilot","Astronaut","Pacifier","Command","Astronaut","Technical","Legal","Medical","Logistics","Marine"); $Posting=array("Small_Ship","Capital_Ship","Logs_Ship","Shipyard","Training","Port_Staff","Special_Duties","Staff","Staff","Naval_Academy","Command","Command","Admiralty", "Command"); $Ranks=array("Ensign", "Lieutenant", "Lt.Commander", "Commander", "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 "

The following Officers have been promoted with effect from 3209.001 \n"; echo " \n \n "; $appl=1; // for each applicant then roll the various dice and then set the variables do { $Experience=rand(0,9); $post=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<5) { $sex="M"; $gend="M"; } elseif($Gender<10) { $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 > 3) { // 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"; } } // work out the officer's rank (before promotion) if($appl<$Ensigns) {$rank=0;} elseif($appl>$RAdms) {rank=5;} elseif($appl>$Capts) {rank=4;} elseif($appl>$Cdrs) {rank=3;} elseif($appl>$LtCdrs) {rank=2;} else {rank=1;} // Modify posting score $posting = $post + $rank; $newrank = $rank++; // 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); // then randomly take a firstname of the correct gender from the same list if ($Gender==$sex) { $Forename = $FirstName; next($row); extract($row); end($row); } } $no=rand(0,9); echo " \n "; $appl++; } while ($appl<=$apps); echo "
last 4 \n Rank \n Firstname \n Surname \n Branch Posting \n Location \n
$no.$post.$gen.$Gender $Ranks[$rank] $Forename $Surname $Branch[$Experience] $Posting[$posting] $Homeworld
";