This is an old revision of the document!


Randomly Generated Officers

<php>

11 work out how many applicants. $apps = rand (6,200); 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 (“Small Ship”, “Capital Ship”, “Logs Ship”, “Shipyard”, “Training”, “Port Staff”, “Special Duties”, “Staff”,“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”, “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 “<h2>Applicant Details</h2> \n \n <form action=recruit.php method=post> <table width = 85% cellpadding = 1>\n <tr> \n <td><b>Last 4 \n <td><b>Rank \n <td><b>Firstname \n <td><b>Surname \n <td><b>Branch \n <td><b>Location \n <td><b>Posting \n </tr>”; $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);

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 = rand(0,25) + $rank if ($promote>25) {$rank++;} echo “ <tr> \n <td>$last4 \n <td>$Ranks[$rank] \n <td>$Forename \n <td>$Surname \n <td>$prev[$Experience] \n <td>$Homeworld \n <td>$crim[$CrimCheck] \n </tr>”; $appl++; } while ($appl⇐$apps); echo “</table>”; echo “</form>”; </php>