This is an old revision of the document!
Randomly Generated Officers
<php>
11 work out how many applicants. $apps = 10; 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 (“Dodgy”, “Murky”, “Minor Offences”, “Minor Offences”, “Clean”, “Clean”, “Clean”, “Clean”, “Clean”, “Clean”); $refs = array (“Poor”, “Guarded”, “Guarded”, “Guarded”, “Average”, “Good”, “Good”, “Good”, “Excellent”, “Excellent”);
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>App \n <td>Firstname \n <td>Surname \n <td>Gender \n <td>Homeworld \n <td>Performance \n <td>Disciplinary \n <td>Branch \n </tr>”; $appl=1; 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 > 5)
{
// 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”]; echo “ <tr> \n <td>$appl \n <td>$Forename \n <td>$Surname \n <td>$sex \n <td>$Homeworld \n <td>$refs[$RefCheck] \n <td>$crim[$CrimCheck] \n <td>$prev[$Experience] \n </tr>”; $appl++; } while ($appl⇐$apps); echo “</table>”; echo “</form>”; </php>