Advertisement
Guest User

Untitled

a guest
May 24th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. <div class="button-group filters-button-group listado">
  2. <button class="button is-checked bttodos" data-filter="todos" onclick="filtrar('todos')">TODOS</button>
  3. <button class="button btnone btc filter" data-filter="visu" onclick="filtrar('visu')">IDENTIDADE VISUAL</button>
  4. <button class="button btnone" data-filter="web" onclick="filtrar('web')">DESENVOLVIMENTO WEB</button>
  5. <button class="button btnone btc" data-filter="grafico" onclick="filtrar('grafico')">MATERIAL GRÁFICO</button>
  6. <button class="button btnone" data-filter="comu" onclick="filtrar('comu')">COMUNICAÇÃO VISUAL</button>
  7. <button class="button btnone btc" data-filter="digi" onclick="filtrar('digi')">MARKETING DIGITAL</button>
  8. </div>
  9.  
  10. <script>
  11. var corpo = "";
  12. function pegaDados()
  13. {
  14. var idUltimo = $("#buttonIdUltimoItem").val();
  15. jQuery.ajax
  16. ({
  17. url: "pegaPortifolio.php?id="+idUltimo,
  18. dataType: "json", //Tipo de Retorno
  19. success:
  20. function(data) {
  21. console.log(data);
  22. var pt1 = "";
  23. var i = 1;
  24. var ultimo_id = 0;
  25.  
  26.  
  27. var size = 0, key;
  28. for (key in data) {
  29. if (data.hasOwnProperty(key)) size++;
  30. }
  31. for(i = 0; i < size; i++){
  32. pt1 +='<div class="element-item filter filtros third-effect '+data[i].menu+'" data-category="transition"><div style="padding:2.5px;"><div style="border: 1px solid #AAAAAA;"><img src="images/port/mini/'+data[i].imageM+'" alt="project 2"><div class="mask"><a href="#portfolioModal54" onclick="portfolioModal('+data[i].id+')" class="portfolio-link info" data-toggle="modal"></a></div><div class="fundo-port"><h1>'+data[i].tipo+'</h1><h2>'+data[i].nome+'</h2></div></div></div></div>';
  33. ultimo_id = data[i].id;
  34. $("#buttonIdUltimoItem").val(ultimo_id);
  35. }
  36. monta_html(pt1);
  37. }
  38. });
  39. filtrar($('#buttonIdUltimoItem').attr('class'));
  40. }
  41. function monta_html(dados){
  42. $(".grid").append(dados); //joga o valor para um elemento html
  43. }
  44. </script>
  45.  
  46. <div class="grid">
  47. <?php
  48. $servidor = '###';
  49. $banco = '###';
  50. $usuario = '###';
  51. $senha = '###';
  52. $link = @mysql_connect($servidor, $usuario, $senha);
  53. $db = mysql_select_db($banco,$link);
  54. $idUltimoItem = 0;
  55. if(!$link)
  56. {
  57. echo "erro ao conectar ao banco de dados!";exit();
  58. }
  59.  
  60.  
  61. $sql = "SELECT * FROM portfolio ORDER BY id DESC limit 6";
  62. $query = mysql_query($sql);
  63.  
  64.  
  65. while($sql = mysql_fetch_array($query)){
  66. $id = $sql["id"];
  67. $idUltimoItem = $id;
  68. $nome = $sql["nome"];
  69. $tipo = $sql["tipo"];
  70. $desc = $sql["desc"];
  71. $menu = $sql["menu"];
  72. $imageM = "images/port/mini/" . $sql["imageM"];
  73. $imageF = $sql["imageF"];
  74. ?>
  75. <div class="element-item filter filtros todos third-effect <?php echo "$menu";?>" data-category="transition">
  76. <div style="padding:2.5px;">
  77. <div style="border: 1px solid #AAAAAA;">
  78. <img src="<?php echo "$imageM"?>" alt="project 2">
  79. <div class="mask">
  80. <a href="#portfolioModal54" class="portfolio-link info" data-toggle="modal" onclick="portfolioModal(<?php echo $id;?>)" value="Executa ajax"></a>
  81. </div>
  82. <div class="fundo-port">
  83. <h1><?php echo "$tipo"?></h1>
  84. <h2><?php echo "$nome"?></h2>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <?php
  90. }
  91. ?> </div>
  92.  
  93. <div id="rend-more">
  94. <button type="button" id="buttonIdUltimoItem" onClick="pegaDados();" value="<?= $idUltimoItem;?>" style="width: 262px; height: 50px; border: 1px solid rgb(84, 128, 128); position: relative; top: 30%; left: 50%; transform: translateX(-50%); cursor: pointer; background-color: white;" class="todos">
  95. <h2 style="text-align: center;color:#4d8984;font-family: 'Gotham-Thin';float: left;font-size: 25px;padding-left: 30px;padding-top: 5px;">CARREGAR</h2>
  96. <h3 style="padding-left: 5px;float: left;font-size: 25px;color:#4d8984;font-family: 'gotham-bold';padding-top: 5px;">+</h3></button>
  97. </div>
  98.  
  99. <?php
  100.  
  101.  
  102. function fn_conexao(){
  103.  
  104.  
  105. $dbuser = "###";
  106. $dbpass = "###";
  107.  
  108.  
  109. try {
  110.  
  111.  
  112. $pdo = new PDO('mysql:host=###;dbname=###', $dbuser, $dbpass);
  113. $pdo -> setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
  114. } catch(Exception $e) {
  115.  
  116.  
  117. echo 'Erro na conexao: ' . $e->getMessage();
  118. }
  119.  
  120.  
  121. return $pdo;
  122. }
  123.  
  124.  
  125. function dados($pdo){
  126.  
  127.  
  128. try {
  129.  
  130.  
  131. if(!isset($_GET['id']) or $_GET['id'] == null){
  132.  
  133.  
  134. $id = 0; //se o GET nao for enviado o for enviado como nullo , a variável ID pega o valor de 0
  135.  
  136.  
  137. }else{
  138.  
  139.  
  140. $id = $_GET['id']; //pega o valor passado via GET
  141. }
  142.  
  143.  
  144. $arr = array();
  145.  
  146.  
  147. $sql = "ALTER DATABASE portfolio CHARSET = UTF8 COLLATE = utf8_general_ci";
  148. $sql = "SELECT * FROM portfolio WHERE id < $id ORDER BY id DESC LIMIT 6";
  149. $stmt = $pdo->prepare($sql);
  150. $stmt->execute();
  151. $linha = $stmt->fetchAll(PDO::FETCH_ASSOC);
  152. if($stmt->rowCount() >= 1){
  153.  
  154.  
  155. return $linha; //retorna o resultado da query
  156.  
  157.  
  158. }else {
  159.  
  160.  
  161. return 0;
  162.  
  163.  
  164. }
  165. } catch(Exception $e) {
  166.  
  167.  
  168. print 'Erro ao inserir os dados no banco: ' . $e->getMessage();
  169. $conexao = desconecta($conexao);
  170.  
  171.  
  172. }
  173. }
  174.  
  175.  
  176. $conexao = fn_conexao();
  177. $dados = dados($conexao);
  178.  
  179.  
  180. $dados = json_encode($dados); //converte o resultado para json
  181.  
  182.  
  183. print $dados; //imprime os dados na tela
  184. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement