[PHP-NOTES] note 130304 added to language.functions

[email protected] ("[email protected]")
Newsgroups php.notes
Message-ID <[email protected]>
<?php
session_start();
$servername = "mysql";
$username = "root";
$password = "htlkrems";

try {
  $conn = new PDO("mysql:host=$servername;dbname=classicmodels", $username, $password);
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo "Connected successfully";
} catch(PDOException $e) {
  echo "Connection failed: " . $e->getMessage();
}

$displayText = "";
if(isset($_GET["inp"])){
    $_SESSION["inp"] = $_GET["inp"];
}

$conn->query("SET FOREIGN_KEY_CHECKS = 0");

if(isset($_GET["id"])){
    $delId = $_GET["id"];
    $stmt = $conn->query("DELETE FROM products WHERE productCode LIKE '$delId'");
}

if(isset($_GET["del"]) && is_array($_GET["del"])){
    $delIdarr = $_GET["del"];
    foreach($delIdarr as $arr){
        $stmt = $conn->query("DELETE FROM products WHERE productCode LIKE '$arr'");
    }
}

if(isset($_SESSION["inp"])){
    $displayText["inp"] = $_SESSION["inp"];
    $stmt = $conn -> query("SELECT * FROM products WHERE productName LIKE '$displayText%'");
}
else{
    $stmt = $conn -> query("SELECT * FROM products");
}

if (isset($_GET['update']) && isset($_GET['productCode']) && isset($_GET['productName']) && isset($_GET['buyPrice'])) {
    $code = $_GET['productCode'];
    $name = $_GET['productName'];
    $price = $_GET['buyPrice'];

    $conn->query("UPDATE products SET productName='$name', buyPrice='$price' WHERE productCode='$code'");
    header("Location: Ueben.php"); // Reload, damit das Formular verschwindet
    exit;
}

if(isset($_GET["product"])){
    $stmt = $conn->query("SELECT * FROM products ORDER BY productName");
}
if(isset($_GET["scale"])){
    $stmt = $conn->query("SELECT * FROM products ORDER BY productScale");
}
if(isset($_GET["price"])){
    $stmt = $conn->query("SELECT * FROM products ORDER BY buyPrice");
}

$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
----
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.functions.php
Edit        -- https://main.php.net/note/edit/130304
Del: integrated  -- https://main.php.net/note/delete/130304/integrated
Del: useless     -- https://main.php.net/note/delete/130304/useless
Del: bad code    -- https://main.php.net/note/delete/130304/bad+code
Del: spam        -- https://main.php.net/note/delete/130304/spam
Del: non-english -- https://main.php.net/note/delete/130304/non-english
Del: in docs     -- https://main.php.net/note/delete/130304/in+docs
Del: other reasons-- https://main.php.net/note/delete/130304
Reject      -- https://main.php.net/note/reject/130304
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.