leonsuke

PDO [getObjek2]

Jul 7th, 2015
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2. require_once ("dbconn.php");
  3.  
  4. try {
  5. $stmnt = $con->prepare("SELECT * FROM barang WHERE id_barang = :id_barang");
  6. $stmnt->bindParam(":id_barang", $_GET["id_barang"], PDO::PARAM_INT);
  7. $stmnt->execute();
  8. $fetch = $stmnt->fetchAll();
  9.  
  10. foreach ($fetch as $value)
  11. {
  12. echo json_encode($value);
  13. exit();
  14. }
  15. }catch (Exception $exc){
  16. // Menampilkan pesan kesalahan
  17. echo "Terjadi kesalahan: ".$exc->getMessage();
  18. }
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment