Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('dbconnect.php');
- //hier word de tabel met alle producten gemaakt
- $sql = "SELECT * FROM product";
- $result = $db->query($sql);
- if ($result->num_rows > 0) {
- echo "<p> <h2>Producten:</h2>";
- //tabel word gemaakt door een while loop en daarin de sql resultaten
- echo "<table><tr><th>Productcode </th><th>Product </th><th>Type </th><th>Fabriekscode </th><th>Inkoopprijs </th><th>Verkoopprijs </th></tr>";
- while($row = $result->fetch_assoc()) {
- echo "<tr><td>".$row["Productcode"]."</td><td>".$row["Product"]."</td><td>".$row["Type"]."</td><td>".$row["Fabriekscode"]."</td><td>€ ".$row["Inkoopprijs"]."</td><td>€ ".$row["Verkoopprijs"]."</td></tr>";
- }
- echo "</table>";
- }
- //hier wordt de voorrad van de producten per locatie getoond
- echo "<p> <h2>Voorraad producten per locatie:</h2>";
- if (isset ($_POST['locatiecode'])) {
- $locatiecode = ($_POST['locatiecode']);
- $sql2 = "SELECT * FROM voorraad WHERE locatiecode='$locatiecode'";
- $result2 = $db->query($sql2);
- if ($result2->num_rows > 0) {
- //tabel word gemaakt door een while loop en daarin de sql resultaten
- echo "<table><tr><th>Locatie </th><th>Productcode </th><th>Aantal </th></tr>";
- while($row = $result2->fetch_assoc()) {
- echo "<tr><td>".$row["Locatiecode"]."</td><td>".$row["Productcode"]."</td><td>".$row["Aantal"]."</td></tr>";
- }
- echo "</table>";
- }
- }
- if (isset ($_POST['productcode2'], $_POST['locatiecode2'], $_POST['aantal2'])){
- $productcode2 = ($_POST["productcode2"]);
- $locatiecode2 = ($_POST["locatiecode2"]);
- $aantal2 = ($_POST['aantal2']);
- //updaten van de vooraad word hier gedaan met een update en set command
- $sql2 = "UPDATE voorraad SET aantal = aantal + '$aantal2' WHERE productcode = '$productcode2' AND locatiecode = '$locatiecode2'";
- if (mysqli_query($db, $sql2)) {
- echo "Voorraad toegevoegd";
- } else {
- echo "Fout bij het toevoegen van voorraad!";
- }
- }
- if (isset ($_POST['locatiecode'])) {
- $locatiecode = ($_POST['locatiecode']);
- $sql3 = "SELECT * FROM voorraad WHERE locatiecode='$locatiecode'";
- $result3 = $db->query($sql3);
- if ($result2->num_rows > 0) {
- //tabel word gemaakt door een while loop en daarin de sql resultaten
- while($row = $result2->fetch_assoc()) {
- }
- echo "</table>";
- }
- }
- // php code to Insert data into mysql database from input text
- if(isset($_POST['insert']))
- {
- $hostname = "localhost";
- $username = "root";
- $password = "";
- $databaseName = "toolsforever";
- // get values form input text and number
- $productcode3 = $_POST['productcode3'];
- $locatiecode3 = $_POST['locatiecode3'];
- $aantal3 = $_POST['aantal3'];
- // connect to mysql database using mysqli
- $connect = mysqli_connect($hostname, $username, $password, $databaseName);
- // mysql query to insert data
- $query = "INSERT INTO `voorraad`(`Productcode`, `Locatiecode`, `Aantal`) VALUES ('$productcode3','$locatiecode3','$aantal3')";
- $result = mysqli_query($connect,$query);
- // check if mysql query successful
- if($result)
- {
- echo 'Data Inserted';
- }
- else{
- echo 'Data Not Inserted';
- }
- mysqli_free_result($result);
- mysqli_close($connect);
- }
- /*if (isset ($_POST['productcode3'], $_POST['locatiecode3'], $_POST['aantal3'])){
- $productcode3 = ($_POST["productcode3"]);
- $locatiecode3 = ($_POST["locatiecode3"]);
- $aantal3 = ($_POST['aantal3']);
- //updaten van de vooraad word hier gedaan met een update en set command
- $sql3 = "INSERT INTO voorraad (Productcode, Locatiecode, Aantal)
- VALUES('$productcode3', '$locatiecode3', '$aantal3')";
- if (mysqli_query($db, $sql3)) {
- echo "Voorraad toegevoegd";
- } else {
- echo "Fout bij het toevoegen van voorraad!";
- }
- }*/
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement