query($query2); while ($row2 = $result2->fetchArray()) { $string = $row2['fullname']; $parts = explode(" ", $string); if ($parts[0] == $_SESSION['username']){ $createEmail = $row2['email']; $createMobile = $row2['mobile']; $createdby = $row2['fullname']; } } $db2->close(); $clientId = isset($_GET['client-id']) ? $_GET['client-id'] : 'No tracking number provided'; $clientIdDecode = base64_decode($clientId); $clientId = $_SESSION['client-id']; // Check if the projects.db file exists, and if not, create it $dbFile4 = $parentDirectory . '/invoices/database/invoices.db'; if (!file_exists($dbFile4)) { $db = new SQLite3($dbFile4); if (!$db) { die("Failed to create the database file."); } // Create the 'projects' table $createQuery = "CREATE TABLE IF NOT EXISTS figures ( id INTEGER PRIMARY KEY AUTOINCREMENT, item TEXT, description TEXT, subtotal TEXT )"; $db->exec($createQuery); if (!$db->exec($createQuery)) { die("Failed to create the 'projects' table."); } $db->close(); } else { $db = new SQLite3($dbFile4); if (!$db) { die("Database connection failed: " . $db->lastErrorMsg()); } } // Function to fetch and display data function displayData($db) { $query = "SELECT id, item, description, subtotal, clientname, mobile, email, address, createdby, invoicefull, projectname, createdate, clientid FROM figures"; $result = $db->query($query); $invoiceNumber = $_SESSION['invoiceNumber']; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { if ($invoiceNumber == $row['invoicefull']){ $clientId = $row['clientid']; $clientname = $row['clientname']; $email = $row['email']; $mobile = $row['mobile']; $address = $row['address']; $createdby = $row['createdby']; $projectname = $row['projectname']; $createdate = $row['createdate']; $projectId = $row['id']; $item = $row['item']; $description = $row['description']; $subtotal = $row['subtotal']; $items = explode(", ", $item); $descriptions = explode(", ", $description); $subtotals = explode(",", $subtotal); for ($i = 0; $i < count($items); $i++) { echo ""; echo "" . $items[$i] . ''; echo "" . $descriptions[$i] . ''; echo "
R" . $subtotals[$i] . "
"; echo ""; echo ''; } } } } if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["update"])) { $updatedData = $_POST["updatedData"]; $projectId = $_POST["projectId"]; } ?> Invoice


" . $clientname . ''; ?> "; // echo $email; echo ""; ?> "; // Connect to the SQLite3 database //echo $mobile; echo ""; ?> " . $address[0] . ''; ?> " . $address[1] . ''; ?> '; echo $createdby; echo ""; echo ''; echo "'; ?> '; echo $createEmail; echo ""; echo ''; echo "'; ?> '; echo $createMobile; echo ""; echo ''; ?> " . $projectname . ''; ?>
Company: Client:
BLACKHOUND ENTERPRISES PTY LTD T/A
BLACKHOUND ARCHITECTURE & RENDERING
Unit 10 - The Network
19 Cactus Road, Fairview, Port Elizabeth
(Gqeberha), Eastern Cape, 6075
" . $address[2] . '
" . $address[3] . '
Date:  " . $createdate. ''; ?>
Invoice No.:
close(); ?>
Item: Description: Sub Total:
Total: (excl. VAT)
R 0.00

Banking Details
Nedbank
Account Number: 1212774191
Branch Code: 12681700
Checque account
KINDLY USE THE INVOICE NUMBER AS YOUR PAYMENT REFERENCE