Advertisement
Guest User

Untitled

a guest
Aug 4th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. <?PHP
  2. class Connection {
  3. // Configure Database Vars
  4. private $host = 'localhost';
  5. private $username = 'name';
  6. private $password = 'pass';
  7. private $db_name = 'db';
  8. public $dbase;
  9.  
  10. function __construct() {
  11. // Create connection
  12. $db = new mysqli($this->host, $this->username, $this->password, $this->db_name);
  13.  
  14. // Check connection
  15. if ($db->connect_errno > 0) {
  16. die('Unable to connect to the database: '.$db->connect_error);
  17. }
  18.  
  19. $this->db = $db;
  20. }
  21.  
  22. public function query($query) {
  23. $db = $this->db;
  24. $this->db->query('SET NAMES utf8');
  25. if (!$result = $this->db->query($query)) {
  26. die('There was an error running the query ['.$db->error.']');
  27. } else {
  28. return $result;
  29. }
  30. }
  31.  
  32. public function multi_query($query) {
  33. $db = $this->db;
  34. if (!$result = $this->db->multi_query($query)) {
  35. die('There was an error running the multi query ['.$db->error.']');
  36. } else {
  37. return $result;
  38. }
  39.  
  40. }
  41.  
  42. public function real_escape_string($value) {
  43. return $this->db->real_escape_string($value);
  44. }
  45.  
  46. public function inserted_id() {
  47. return $this->db->insert_id;
  48. }
  49. }
  50.  
  51. $conn = new Connection;
  52.  
  53. // Websites
  54. $web = "SELECT * FROM `name` WHERE catid = 9 AND state = 1 ORDER BY ordering LIMIT 0,".$_POST['limit']."";
  55. $webcon = $conn->query($web);
  56. $webcr = array();
  57. while ($webcr[] = $webcon->fetch_array());
  58.  
  59. foreach($webcr as $website){
  60. $web_images = $website['images'];
  61. $web_imgs = json_decode($web_images);
  62.  
  63. if($website['title'] != ''){
  64. if($web_imgs->{'image_intro'}){
  65. $weboverzicht .= '
  66. <div class="col-md-4 wow fadeIn" data-wow-duration="2s" style="padding:0px">
  67. <div class="post">
  68. <div class="post-heading">
  69. <a style="max-height: 220px;" class="post-image" href="'.$website['alias'].'.html">
  70. <img class="websiteimg" src="cms/'.$web_imgs->{'image_intro'}.'" class="" alt="post" />
  71. </a>
  72. </div>
  73. <div class="post-body" style="min-height:70px;border:none;">
  74. <a href="'.$website['alias'].'.html"><h5>'.$website['title'].'</h5></a>
  75. <p class="lijnhoogte">'.strip_tags($website['introtext']).'</p>
  76. <p class="bekijkproject2"><a class="infolink" href="'.$website['alias'].'.html">Bekijk project</a></p>
  77. </div>
  78. </div>
  79. </div>';
  80. }else{
  81. $weboverzicht .= '
  82. <div class="col-md-4 wow fadeIn" data-wow-duration="2s" style="padding:0px">
  83. <div class="post">
  84. <div class="post-heading">
  85. <a style="max-height: 220px;" class="post-image" href="'.$website['alias'].'.html">
  86. <img class="websiteimg" src="image.jpg" class="" alt="post" />
  87. </a>
  88. </div>
  89. <div class="post-body" style="min-height:70px;border:none;">
  90. <a href="'.$website['alias'].'.html"><h5>'.$website['title'].'</h5></a>
  91. <p class="lijnhoogte">'.strip_tags($website['introtext']).'</p>
  92. <p class="bekijkproject2"><a class="infolink" href="'.$website['alias'].'.html">Bekijk project</a></p>
  93. </div>
  94. </div>
  95. </div>';
  96. }
  97. }
  98. }
  99. echo $weboverzicht;
  100. ?>
  101.  
  102. (function(){
  103. /*
  104. Meer websites laden
  105. */
  106. var limit = 3;
  107.  
  108. $('#loadmore').click(function() {
  109. limit += 3;
  110.  
  111. ajax();
  112.  
  113. });
  114.  
  115. var posts = document.getElementById('loadnews');
  116.  
  117. function ajax() {
  118. $.ajax({
  119. url: 'includes/loadmore.php',
  120. type: "POST",
  121. data: {limit: limit},
  122. success: function(data){
  123. loadnews.innerHTML = data;
  124. },
  125. error: function(jqXHR, exception) {
  126. if (jqXHR.status === 0) {
  127. alert('Not connect.n Verify Network.');
  128. } else if (jqXHR.status == 404) {
  129. alert('Requested page not found. [404]');
  130. } else if (jqXHR.status == 500) {
  131. alert('Internal Server Error [500].');
  132. } else if (exception === 'parsererror') {
  133. alert('Requested JSON parse failed.');
  134. } else if (exception === 'timeout') {
  135. alert('Time out error.');
  136. } else if (exception === 'abort') {
  137. alert('Ajax request aborted.');
  138. } else {
  139. alert('Uncaught Error.n' + jqXHR.responseText);
  140. }
  141. }
  142. });
  143. }
  144.  
  145. ajax();
  146. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement