在使用PHP邮寄表单时使用if else if语句?

I have a form where I only want certain information to be emailed to an account depending on their selection from a select tag in the form.

Here is my HTML of the select tag:

<select id="numberofstaff">
    <option class="staffselection" value="">--Select--</option>
    <option class="staffselection" value="smalljobsite">1-3 staff</option>
    <option class="staffselection" value="mediumjobsite">4-7 staff</option>
    <option class="staffselection" value="largejobsite">8+ staff</option>
</select>

Here is my PHP that I'm having the issue with:

<?php
if (isset($_POST['primaryemail']) && isset($_POST['numberofstaff'])){
    $numberofstaff = $_POST['numberofstaff'];
    $smallplantable = $_POST['smallplantable'];
    $smallcopierone = $_POST['smallcopierone'];
    $smallcopiertwo = $_POST['smallcopiertwo'];
    $mediumtrailers = $_POST['mediumtrailers'];
    $mediumplantable = $_POST['mediumplantable'];
    $wifi = $_POST['wifi'];
    $mediumcopierone = $_POST['mediumcopierone'];
    $mediumcopiertwo = $_POST['mediumcopiertwo'];
    $largetrailers = $_POST['largetrailers'];
    $largeplantable = $_POST['largeplantable'];
    $largewifi = $_POST['largewifi'];
    $largecopierone = $_POST['largecopierone'];
    $largecopiertwo = $_POST['largecopiertwo'];
    $numberofstaff = $_POST['numberofstaff'];
    $smallplantable= $_POST['smallplantable'];
    $smallcopierone= $_POST['smallcopierone'];
    $smallcopiertwo= $_POST['smallcopiertwo'];
    $mediumtrailers= $_POST['mediumtrailers'];
    $mediumplantable= $_POST['mediumplantable'];
    $wifi= $_POST['wifi'];
    $mediumcopierone= $_POST['mediumcopierone'];
    $mediumcopiertwo= $_POST['mediumcopiertwo'];
    $largetrailers= $_POST['largetrailers'];
    $largeplantable= $_POST['largeplantable'];
    $largewifi= $_POST['largewifi'];
    $largecopierone= $_POST['largecopierone'];
    $largecopiertwo= $_POST['largecoipertwo'];

if (!empty($primaryemail) && $numberofstaff == 'smalljobsite') {
    $to = 'testemail@test.com';
    $subject = 'Jobsite Form Submitted';
    $body = Number of Users: " . $numberofstaff . "
Plan Table: " . $smallplantable . "
C5035: " . $smallcopierone . "
C5045: " . $smallcopiertwo;
    $headers = 'From:' . $primaryemail;
    mail($to, $subject, $body, $headers);   
}
else if (!empty($primaryemail) && $numberofstaff == 'mediumjobsite') {
    $to = testemail@test.com';
    $subject = 'Jobsite Form Submitted';
    $body = "Number of Users: " . $numberofstaff . "
Trailer(s) or Similar Sized Office(s): " . $mediumtrailers . "
Plan Table(s): " . $mediumplantable . "
External Wifi: " . $wifi . "
C5035: " . $mediumcopierone . "
C5045: " . $mediumcopiertwo;
    $headers = 'From:' . $primaryemail;
    mail($to, $subject, $body, $headers);   
}
else if (!empty($primaryemail) && $numberofstaff == 'largejobsite') {
    $to = 'testemail@test.com';
    $subject = 'Jobsite Form Submitted';
    $body = "Number of Users: " . $numberofstaff . "
Trailer(s) or Similar Sized Office(s): " . $largetrailers . "
Plan Table(s): " . $largeplantable . "
External Wifi: " . $largewifi . "
C5035: " . $largecopierone . "
C5045: " . $smallcopiertwo;
    $headers = 'From:' . $primaryemail;
        mail($to, $subject, $body, $headers);   
    }
}

The code works fine with just the one if statement to check make sure primaryemail is not empty. However, when I added the else if statements to change what is sent based on what is selected in the numberofstaff id it fails to work.

Any help is appreciated. I don't see why this wouldn't be possible.

I changed your code around a bit, added a switch on $numberofstaff and moved the mail $to, $from and actual mail functions outside the if clauses.

Also you had some quotes missing in some if statements.
Have a look

<?php
if (isset($_POST['primaryemail']) && isset($_POST['numberofstaff'])){
    $numberofstaff = $_POST['numberofstaff'];
    $smallplantable = $_POST['smallplantable'];
    $smallcopierone = $_POST['smallcopierone'];
    $smallcopiertwo = $_POST['smallcopiertwo'];
    $mediumtrailers = $_POST['mediumtrailers'];
    $mediumplantable = $_POST['mediumplantable'];
    $wifi = $_POST['wifi'];
    $mediumcopierone = $_POST['mediumcopierone'];
    $mediumcopiertwo = $_POST['mediumcopiertwo'];
    $largetrailers = $_POST['largetrailers'];
    $largeplantable = $_POST['largeplantable'];
    $largewifi = $_POST['largewifi'];
    $largecopierone = $_POST['largecopierone'];
    $largecopiertwo = $_POST['largecopiertwo'];
    $numberofstaff = $_POST['numberofstaff'];
    $smallplantable= $_POST['smallplantable'];
    $smallcopierone= $_POST['smallcopierone'];
    $smallcopiertwo= $_POST['smallcopiertwo'];
    $mediumtrailers= $_POST['mediumtrailers'];
    $mediumplantable= $_POST['mediumplantable'];
    $wifi= $_POST['wifi'];
    $mediumcopierone= $_POST['mediumcopierone'];
    $mediumcopiertwo= $_POST['mediumcopiertwo'];
    $largetrailers= $_POST['largetrailers'];
    $largeplantable= $_POST['largeplantable'];
    $largewifi= $_POST['largewifi'];
    $largecopierone= $_POST['largecopierone'];
    $largecopiertwo= $_POST['largecoipertwo'];

if (!empty($primaryemail)){
    $to = 'testemail@test.com'; // moved here since they don't seem to depend on $number of staff
    $subject = 'Jobsite Form Submitted'; // moved here since they don't seem to depend on $number of staff
    $headers = 'From:' . $primaryemail;

    switch($numberofstaff){
        case 'smalljobsite':
            $body = "Number of Users: " . $numberofstaff . "
Plan Table: " . $smallplantable . "
C5035: " . $smallcopierone . "
C5045: " . $smallcopiertwo;
        break;
        case 'mediumjobsite':
            $body = "Number of Users: " . $numberofstaff . "
Trailer(s) or Similar Sized Office(s): " . $mediumtrailers . "
Plan Table(s): " . $mediumplantable . "
External Wifi: " . $wifi . "
C5035: " . $mediumcopierone . "
C5045: " . $mediumcopiertwo;
        break;
        case 'largejobsite':
            $body = "Number of Users: " . $numberofstaff . "
Trailer(s) or Similar Sized Office(s): " . $largetrailers . "
Plan Table(s): " . $largeplantable . "
External Wifi: " . $largewifi . "
C5035: " . $largecopierone . "
C5045: " . $smallcopiertwo;
        break;
    }

    mail($to, $subject, $body, $headers);
}
isset($_POST['numberofstaff'])

This will never be set, because you don't have a form element by that name. You have this:

<select id="numberofstaff">

Posted form values are by name, not by id:

<select id="numberofstaff" name="numberofstaff">