l105/PO Informatica P4/po informatica/assortiment.php

<?php $edit = $_GET['edit']; $productid = $_GET['productid']; $productNaam = $_GET['productNaam']; $details = $_GET['assortimentDetails']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link href="style.css?t=<?php echo time();?>(>)" rel= "stylesheet" type=text/css> <script src='ajax.js'></script> <script> window.onload = laadAjax; function laadAjax() { document.getElementById('zoekbalk').onkeyup = zoekAjax; } function zoekAjax() { var zoeken = document.getElementById("zoekbalk1").value; // document.write(zoeken); ajax('assortimentDetails.php?zoeken=' + zoeken, 'zoekendiv'); } </script> </head> <body> <?php if(isset($_GET['edit'])){ $edit=$_GET['edit']; echo "<button><a href='assortiment.php?'>Terug</a></button>"; } else{ $edit=null; } include('db.php'); include('functies.php'); include('navbar.php'); if(!$edit && !$details){ ?> <form action="" method="get"> <div style="text-align: center;" id="zoekbalk"> zoekbalk <input type="text" name="zoekbalk" id="zoekbalk1"> <input type="submit" name="zoeken" id="zoeken"> <div id="zoekendiv"> <?php $query = "SELECT * FROM producten"; $result = mysqli_query($db, $query); echo '<div><h2>Product</h2></div>'; while ($row = mysqli_fetch_array($result)) { echo"<div>"; echo "<a class='productButton' href='assortiment.php?assortimentDetails=$row[0]'>$row[1], €$row[3] </a>"; if($admin == true) { echo "|| <a class='wijzigInfoButton' href='assortiment.php?edit=$row[0]'>wijzig informatie</a> <br>"; } echo "<br><img class='productFoto' src='images/$row[0].png' alt='productfoto'><br>"; echo"</div>"; } } ?> </form> <?php if($details) { $details = $_GET['assortimentDetails']; echo "<div><a href='assortiment.php'>terug</a></div>"; $query = "select * from producten where productID = $details"; $result = mysqli_query($db, $query) or die(mysqli_error($db)); $rowdetail = mysqli_fetch_array($result); echo "<br>"; echo "<div>Product naam: $rowdetail[1]</div>"; echo "<br>"; echo "<div>vegatarisch: $rowdetail[2]</div>"; echo "<br>"; echo "<div>prijs: $rowdetail[3]</div>"; echo "<img src='images/$rowdetail[0].png' alt='productfoto'>"; } if($edit) { $edit = $_GET['edit']; $query = "select * from producten where productID = $edit"; $result = mysqli_query($db, $query) or die(mysqli_error($db)); $rowedit = mysqli_fetch_array($result); echo "<br>"; echo "<form method='get'>"; echo "product naam: <input type='text' value='$rowedit[1]'> "; echo "<br>"; echo "Vegetarisch: <input type='text' value='$rowedit[2]'>"; echo "<br>"; echo "prijs: <input type='text' value='$rowedit[3]'>"; echo "<br>"; echo "<input type='submit' value='aanpassen'>"; echo "<br>"; echo "<img src='images/$rowedit[0].png' alt='productfoto'>"; echo "</form>"; } ?> </body> </html>

Resultaat

Made by Thijs Aarnoudse