Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Exercice 3
- <?php
- /*(1)*/
- $con = mysqli_connect("localhost", "root", "","testBD");
- /*(2)*/
- $req = "SELECT * FROM Client ORDERED BY nom";
- $res = mysqli_query($con, $req);
- while($row = mysqli_fetch_array($res))
- echo "$row[0] $row[1] $row[2] $row[3] <br>";
- /*(3)*/
- $req = "SELECT * FROM Produit WHERE QStocke <= 50";
- mysqli_query($con, $res);
- echo "<html>
- <script>alert($mysqli_affected_rows($con))</script>
- </html>";
- /*(4)*/
- $stmt = $dbh->prepare("INSERT INTO Produit VALUES(?, ?, ?, ?)");
- $stmt = bindParam(1,$nump);
- $stmt = bindParam(2,$nomp);
- $stmt = bindParam(3,$prix);
- $stmt = bindParam(4,$qte);
- $nump = 1;
- $nomp = "prod 1";
- $prix = 100;
- $qte = 50;
- $stmt->execute();
- $nump = 2;
- $nomp = "prod 2";
- $prix = 250;
- $qte = 33;
- $stmt->execute();
- /*(5)*/
- $req = "INSERT INTO Produit VALUES(1, 'prod 1', 100, 50);INSERT INTO Produit VALUES(2, 'prod 2', 250, 33)";
- mysqli_multi_query($con, $req);
- /*(6)*/
- echo "<html>
- <body>
- <form methode = 'post' action = 'aff.php'>
- <input type = 'text' name = 'num'>
- <input type = 'submit' value = 'Rechercher'>
- </form>
- </body>
- </html>";
- ?>
- //aff.php
- <?php
- $num = $_POST["num"];
- $con = mysqli_connect("localhost", "root", "","testBD");
- $req = "SELECT NumP, NomP, Qte FROM Produit p, Commande c, Ligne_commande c where $num = l.numCmd and $num = c.numCmd and p.numP = l.NumP";
- $res = mysqli_query($con, $req);
- while($row = mysqli_fetch_array($con, $res)) {
- echo "<html>
- <body>
- <table>
- <tr>
- <td>$row[0]</td>
- <td>$row[1]</td>
- <td>$row[2]</td>
- </tr>";
- }
- echo "</table> </body> </html>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement