Guest User

Untitled

a guest
Oct 25th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <?php
  2. namespace RccgPraiseCentreUser;
  3.  
  4.  
  5. class HomeMenu{
  6. public $errorArray = array();
  7.  
  8. private $db;
  9.  
  10. function __construct($db)
  11. {
  12. $this -> db = $db;
  13. }
  14.  
  15.  
  16.  
  17. //display all slider base on id
  18. public function bannerSlider($id){
  19. $query = $this->db->prepare("SELECT * FROM slider_tbl WHERE id = ? LIMIT 1");
  20. $query->execute(array($id));
  21. if($query->rowCount()>0){
  22. $result = $query->fetch(PDO::FETCH_ASSOC);
  23. return $result;
  24. }else{
  25. echo '<h2 style="color:white;">RCCG Praise Centre Area Headquater</h2>';
  26. }}
  27.  
  28. <?php
  29. include_once"includeFiles/dbconfig.php";
  30.  
  31. require_once __DIR__.'/../vendor/autoload.php';
  32. use RccgPraiseCentreUserHomeMenu as HomeMenu;
  33.  
  34.  
  35. $object = new HomeMenu($db);
  36. echo $object->bannerSlider('1')['header_title'];
  37.  
  38. ?>
  39.  
  40. <?php
  41.  
  42. $DB_host = "localhost";
  43. $DB_user = "root";
  44. $DB_pass = "";
  45. $DB_name = "rccgpraisecentre";
  46.  
  47. try
  48. {
  49. $db = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
  50. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  51. }
  52. catch(PDOException $e)
  53. {
  54. echo $e->getMessage();
  55. }
Add Comment
Please, Sign In to add comment