$result = mysql_query($sql, $conn) or die(mysql_error());
$array = mysql_fetch_array($result);
$user_name_first = $array['user_name_first'];
$user_name_second = $array['user_name_second'];
$printed_on = "Current at " . date("g:ia, j F Y");
$pdf->Cell(0, 6, $printed_on, 0, 1, L, 0);
$pdf->SetFillColor(255, 255, 255);
$y_current = 70;
$x_current = 10;
// Project Address
$proj_address = $proj_address . AddLine($proj_address_1);
$proj_address = $proj_address . AddLine($proj_address_2);
$proj_address = $proj_address . AddLine($proj_address_3);
$proj_address = $proj_address . AddLine($proj_address_town);
$proj_address = $proj_address . AddLine($proj_address_county);
$proj_address = $proj_address . AddLine($proj_address_postcode);
StyleHeading("Site Address", $proj_address);
// Begin the conditions array
$sql_conditions = "SELECT * FROM intranet_projects_planning LEFT JOIN contacts_companylist ON company_id = condition_responsibility WHERE condition_project = {$proj_id} ORDER BY condition_decision_date, condition_ref, condition_number";
$result_conditions = mysql_query($sql_conditions, $conn) or die(mysql_error());
if (mysql_num_rows($result_conditions) > 0) {
    unset($current_ref);
    while ($array_conditions = mysql_fetch_array($result_conditions)) {
        if ($pdf->GetY() > 200) {
            $pdf->addPage();
        }
        if ($array_conditions['condition_type'] == "Informative Only") {
            $condition_approved = "Not required";
        } elseif ($array_conditions['condition_approved'] != "0000-00-00") {
            $condition_approved = date("j M Y", AssessDays($array_conditions['condition_approved']));
        } elseif ($array_conditions['condition_submitted'] != "0000-00-00") {
    }
    $contact_proj_note = $array_contacts['contact_proj_note'];
    $contact = $contact_namefirst . " " . $contact_namesecond . "\n";
    $contact = $contact . AddLine($contact_title);
    if ($contact_company > 0) {
        $contact = $contact . AddLine($company_name);
        $contact = $contact . AddLine($company_address);
        $contact = $contact . AddLine($company_city);
        $contact = $contact . AddLine($company_county);
        $contact = $contact . AddLine($company_postcode);
        $company_phone_print = "T. " . $company_phone;
        $contact = $contact . AddLine($company_phone_print);
    } else {
        $contact = $contact . AddLine($contact_address);
        $contact = $contact . AddLine($contact_city);
        $contact = $contact . AddLine($contact_county);
        $contact = $contact . AddLine($contact_postcode);
        $contact_phone_print = "T. " . $contact_phone;
        $contact = $contact . AddLine($contact_phone_print);
    }
    $contact_mobile_print = "M. " . $contact_mobile;
    $contact = $contact . AddLine($contact_mobile_print);
    $contact_email_print = "E. " . $contact_email;
    $contact = $contact . AddLine($contact_email_print);
    $contact_web_print = "W. " . $company_web;
    $contact = $contact . AddLine($contact_web_print);
    StyleHeading($discipline_name, $contact, $contact_proj_note);
    $count++;
}
// and send to output
$pdf->Output();