query("SELECT orders.*, users.email, users.fullname FROM orders LEFT JOIN users ON orders.id = users.order_id WHERE users.email='$email'"); $order = $result->fetch_assoc(); $result = $conn->query("SELECT * FROM docs WHERE email='$email'"); $docs = []; if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { array_push($docs, $row); } } $queries = array(); parse_str($_SERVER['QUERY_STRING'], $queries); $doc_id = array_key_exists('doc', $queries) ? $queries['doc'] : (count($docs) ? $docs[0]['id'] : ""); $doc = $doc_id ? $conn->query("SELECT * FROM docs WHERE id=$doc_id")->fetch_assoc() : null; require 'templates/document_tmpl.php'; ?>