[PHP-NOTES] note 130168 added to faq.general

[email protected] ("Anonymous")
Newsgroups php.notes
Message-ID <[email protected]>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <title>Document</title>
</head>
<body>
    <?php

        // Verbindung zur Datenbank herstellen mit PDO
        $servername = "mysql";
        $username = "root";
        $password = "htlkrems";
        $dbname = "classicmodels";

        try {
            $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch (PDOException $e) {
            die("Verbindung fehlgeschlagen: " . $e->getMessage());
        }

        $id = isset($_GET['id']) ? $_GET['id'] : null;

        if ($id) {
            $stmt = $conn->prepare("SELECT * FROM customers WHERE customerNumber = :id");
            $stmt->bindParam(':id', $id, PDO::PARAM_STR);
            $stmt->execute();
            $results = $stmt->fetch(PDO::FETCH_ASSOC);
        } else {
            $results = false; // Falls keine ID übergeben wurde
        }
    ?>
    <?php
    
        if ($results) { // Überprüfung, ob Ergebnisse vorhanden sind
            echo "<table class='table table-striped'>";
            echo "<tr>";
                    echo "<th>customerNumber</th>";
                    echo "<th>customerName</th>";
                    echo "<th>contactLastName</th>";
                    echo "<th>contactFirstName</th>";
                    echo "<th>phone</th>";
                    echo "<th>addressLine1</th>";
                    echo "<th>addressLine2</th>";
                    echo "<th>city</th>";
                    echo "<th>state</th>";
                    echo "<th>postalCode</th>";
                    echo "<th>country</th>";
                    echo "<th>salesRepEmployeeNumber</th>";
                    echo "<th>creditLimit</th>";
            echo "</tr>";

            echo "<tr>";
            echo "<td>" . $results['customerNumber'] . "</td>";
            echo "<td>" . $results['customerName'] . "</td>";
            echo "<td>" . $results['contactLastName'] . "</td>";
            echo "<td>" . $results['contactFirstName'] . "</td>";
            echo "<td>" . $results['phone'] . "</td>";
            echo "<td>" . $results['addressLine1'] . "</td>";
            echo "<td>" . $results['addressLine2'] . "</td>";
            echo "<td>" . $results['city'] . "</td>";
            echo "<td>" . $results['state'] . "</td>";
            echo "<td>" . $results['postalCode'] . "</td>";
            echo "<td>" . $results['country'] . "</td>";
            echo "<td>" . $results['salesRepEmployeeNumber'] . "</td>";
            echo "<td>" . $results['creditLimit'] . "</td>";
            echo "</tr>";

            echo "</table>";
        } else {
            echo "<p>Keine Employee mit dieser Checknummer gefunden.</p>";
        }
  ?>
</body>
</html>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 193.170.70.42)
----
Manual Page -- https://php.net/manual/en/faq.general.php
Edit        -- https://main.php.net/note/edit/130168
Del: integrated  -- https://main.php.net/note/delete/130168/integrated
Del: useless     -- https://main.php.net/note/delete/130168/useless
Del: bad code    -- https://main.php.net/note/delete/130168/bad+code
Del: spam        -- https://main.php.net/note/delete/130168/spam
Del: non-english -- https://main.php.net/note/delete/130168/non-english
Del: in docs     -- https://main.php.net/note/delete/130168/in+docs
Del: other reasons-- https://main.php.net/note/delete/130168
Reject      -- https://main.php.net/note/reject/130168
Search      -- https://main.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.