voila tous les codes qui gere mes Categories et ainsi que tout en bas le codes SQL pour les categories
connection.php
<?php
function dbConnect() {
return new mysqli("localhost","root","","dwm_ecom_2");
}
$dbConnect = dbConnect();
?>
addCategorie.php
<?php
require_once("connection.php");
$nc = $_POST["nomCat"];
$d = $_POST["description"];
$req= $dbConnect->query("INSERT INTO categories (nom_cat,description) VALUES('$nc','$d')");
header("Location:GestionCategories.php");
?>
categorie.php
<?php
require_once("connection.php");
$dbConnect = dbConnect();
$req= $dbConnect->query("SELECT code_cat,nom_cat FROM categories");
?>
<table>
<?php
while($cat=$req->fetch_assoc()) {
?>
<tr>
<td>
<a href="index.php?idCat=<?php echo($cat['code_cat'])?>"><?php echo($cat['nom_cat'])?></a>
</td>
</tr>
<?php
}
?>
</table>
GestionCategorie.php
<?php
session_start();
require_once("connection.php");
$req = $dbConnect->query("SELECT code_cat,nom_cat,description FROM categories");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Management-Kategorien</title>
<link rel="stylesheet" type="text/css" href="style1.css" />
<script language="javascript">
function confirmation(idCat){
var rep=confirm("Sind sie sicher diese Kategorie zu löschen ?");
if(rep==true){
document.location="supprimerCategorie.php?idCat="+idCat
}
}
</script>
</head>
<body>
<?php require_once("entete.php"); ?>
<div id="formCategories" align="center">
<form method="post" action="addCategogie.php">
<table>
<tr>
<td>Kategorie:</td>
<td><input type="text" name="nomCat" required="required"></td>
</tr>
<tr>
<td>Beschreibung:</td>
<td><textarea name="description" rows="3" cols="50"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Hinzufügen" /></td>
</tr>
</table>
</form>
</div>
<div id="listeCategories" align="center">
<table border="1">
<tr>
<th>CODE CAT</th><th>NAME CAT</th><th>Beschreibung</th>
</tr>
<?php while($cat = $req->fetch_assoc()){?>
<tr>
<td><?php echo($cat['code_cat'])?></td>
<td><?php echo($cat['nom_cat'])?></td>
<td><?php echo($cat['description'])?></td>
<td>
<a href="javascript:confirmation(<?php echo($cat['code_cat'])?>)">Löschen</a>
</td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>
categories.sql
CREATE TABLE `categories` (
`CODE_CAT` int(11) NOT NULL,
`NOM_CAT` varchar(250) COLLATE utf8_german2_ci NOT NULL,
`DESCRIPTION` text COLLATE utf8_german2_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;
--
-- Daten für Tabelle `categories`
--
INSERT INTO `categories` (`CODE_CAT`, `NOM_CAT`, `DESCRIPTION`) VALUES
(1, 'ISOKE_1', ''),
(2, 'ISOKE_2', ''),
(3, 'ISOKE_3', ''),
(4, 'ISOKE_4', ''),
(5, 'ISOIN', '');