[PHP-NOTES] note 130196 added to language.constants

[email protected] ("[email protected]")
Newsgroups php.notes
Message-ID <[email protected]>
<?php
session_start();

// Datenbankverbindung etablieren
$servername = "mysql";
$username = "root";
$password = "htlkrems";

try {
  // Instanz des PDO Objektes erzeugen
  $conn = new PDO("mysql:host=$servername;dbname=classicmodels", $username, $password);
  // PDO Error Mode auf Exception setzen
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  //echo "Connected successfully"; // Ausgabe wenn DB-Verbindung ok
} catch(PDOException $e) {
  // Ausgabe der Fehlermeldung falls DB-Verbindung fehlgeschlagen
  echo "Connection failed: " . $e->getMessage();
}
$displaytext="";

if(isset($_POST['inp'])){
  $_SESSION['inp'] = $_POST['inp'];
}

if(isset($_SESSION['inp'])){
    $inputText = $_SESSION['inp'];
    $stmt = $conn->query("SELECT * FROM offices WHERE city LIKE '$inputText%'");   // SQL Query ausführen
    $displaytext = $inputText;
}
else if(isset($_GET['letter'])){
  $letter = $_GET['letter']; 
  $_SESSION['letter'] = $letter;
  $let = $_SESSION['letter'];
  $stmt = $conn->query("SELECT * FROM offices WHERE city LIKE '$let%'");
}
else{
    $stmt = $conn->query("SELECT * FROM offices");   // SQL Query ausführen
}

$conn->query("SET FOREIGN_KEY_CHECKS = 0");
 
if(isset($_GET['id'])){
    $delCode = $_GET['id'];
    $stmt = $conn->query("DELETE FROM offices WHERE city like '$delCode'");
}
if(isset($_GET['subDel']))
if (isset($_GET['del']) && is_array($_GET['del'])){
        $delID = $_GET['del'];
        foreach($delID as $del){
            $stmt = $conn->query("DELETE FROM offices WHERE city like '$del'");
        }
    }
 

if(isset($_GET['city'])){
  $stmt = $conn->query("SELECT * FROM offices ORDER BY city");   
}
if(isset($_GET['phone'])){
  $stmt = $conn->query("SELECT * FROM offices ORDER BY phone");   
}
if(isset($_GET['adressLine1'])){
  $stmt = $conn->query("SELECT * FROM offices ORDER BY addressLine1");   
}
if(isset($_GET['country'])){
  $stmt = $conn->query("SELECT * FROM offices ORDER BY country");   
}
if(isset($_GET['postalCode'])){
  $stmt = $conn->query("SELECT * FROM offices ORDER BY postalCode");   
}
if(isset($_GET['territory'])){
  $stmt = $conn->query("SELECT * FROM offices ORDER BY territory");   
}

$result = $stmt->fetchAll(PDO::FETCH_ASSOC);      // alle Daten mit fetchAll fetchen -> Ergebnis ist ein 2-dimensionales Array

$_SESSION['res'] = $result;

?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 193.170.70.27)
----
Manual Page -- https://php.net/manual/en/language.constants.php
Edit        -- https://main.php.net/note/edit/130196
Del: integrated  -- https://main.php.net/note/delete/130196/integrated
Del: useless     -- https://main.php.net/note/delete/130196/useless
Del: bad code    -- https://main.php.net/note/delete/130196/bad+code
Del: spam        -- https://main.php.net/note/delete/130196/spam
Del: non-english -- https://main.php.net/note/delete/130196/non-english
Del: in docs     -- https://main.php.net/note/delete/130196/in+docs
Del: other reasons-- https://main.php.net/note/delete/130196
Reject      -- https://main.php.net/note/reject/130196
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.