query("SELECT ArtNr,Name,isactive FROM produkte order by ArtNr ASC"); #Dropdown zusammenbauen echo ""; echo ""; }else{ #Funktion edit_product aufrufen edit_product(); } } #Funtkion für Product bearbeitung function edit_product() { if ($_POST['Produkt'] == 0 ){ print ""; }else{ global $con; #Produktid setzen $ArtNr = $_POST['Produkt']; #Daten des Produkts Laden $result= $con->query("SELECT * FROM produkte where ArtNr = $ArtNr"); #Tabelle aus array des Produkts füllen while($produkt = mysqli_fetch_array($result)) { echo '

'.$produkt["ArtNr"].'

'; } echo ''; } } #Funktion Product settings speichern function update_product() { global $con; $U_ArtNr = $_POST['U_ArtNr']; $U_Name = $_POST['U_Name']; $U_Preis = $_POST['U_Preis']; $U_Image = $_POST['U_Image']; $U_isactive = $_POST['U_isactive']; #Änderungen in datenbank schreiben $sql = $con->query("UPDATE produkte SET Name='{$U_Name}', Preis='{$U_Preis}', produkt_image='{$U_Image}', isactive='{$U_isactive}' where ArtNr=$U_ArtNr"); } function img_upload() { if (!empty($_FILES["file"])) { $errors= array(); $file_name = $_FILES['file']['name']; $file_size =$_FILES['file']['size']; $file_tmp =$_FILES['file']['tmp_name']; $file_type=$_FILES['file']['type']; $uploaddir = "./Images/"; $uploadfile = $uploaddir . basename($file_name); if($_FILES['file']['size'] > 2097152){ $errors='Error: Datei darf nicht über 2 MB groß sein'; } if(empty($errors)==true){ move_uploaded_file($file_tmp, $uploadfile); print ""; }else{ print ""; } } } #Button Überprüfen und Funktion auffrufen if(isset($_POST['ProductUpdate'])){ update_product(); } if(isset($_POST['InsertNewProdukt'])){ $resultinsert = $con->query("insert into produkte (Name,Preis,produkt_image) VALUES ('{$_POST['NewProduktName']}','{$_POST['NewProduktPreis']}','{$_POST['NewProduktImage']}')"); } if(isset($_POST['Upload'])){ img_upload(); } #Header und menü einbinden $webpagetitle = "Produkt Verwaltung"; include "Includes/Header.php"; include "Includes/Menu.php"; #html Content ausgeben ?>


Produkt hinzufügen


Bild Upload


Bitte bild hochladen (2MB):
ArtNr Name Preis Image IsActive