
Scroll ajax php mysql No carga datos
Publicado por julian (2 intervenciones) el 28/01/2018 16:44:16
Hola chicos, espero me puedan ayudar, estoy teniendo problemas con mi scroll, recibo datos mediante GET para separar la visualización en categorias, el tema es que cuando ejecuto el scroll no carga datos, no se si estoy teniendo un error en el envio de datos, soy nuevo en esto ojala puedan ayudarme.
1.php
2.php
saludos y muchas gracias.
1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
session_start();
require_once 'class.user.php';
$user_home = new USER();
if(!$user_home->is_logged_in())
{
$user_home->redirect('index.php');
}
$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Publicaciones</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/portfolio-item.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="inicio.php">PhCoAviSos.CoM</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right " id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown navbar-right ">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-user"></i><?php echo $row['userEmail']; ?> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="publicaciones.php"><i class="fa fa-fw fa-user"></i> Mis Publicaciones</a>
</li>
<li>
<a href="#"><i class="fa fa-fw fa-envelope"></i> Perfil</a>
</li>
<li class="divider"></li>
<li>
<a href="logout.php"><i class="fa fa-fw fa-power-off"></i> Salir</a>
</li>
</ul>
</li>
<li class="dropdown navbar-right ">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-user"></i>Categorias<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="publicaciones.php"><i class="fa fa-fw fa-user"></i><?php include
("categorias2.php"); ?></a>
</li>
</ul>
</li>
<li>
<a href="publicar.php">Publicar</a>
</li>
<li>
<a href="#">Contacto</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- container -->
<div class="container">
<div class="row">
<?php
if(isset($_GET['cat']) && !empty($_GET['cat']))
{
$video_id = '';
$id = $_GET['cat'];
$stmt = $user_home->runQuery('SELECT email, nombre, telefono, descripcion, img , categoria FROM tbl_public WHERE categoria=:uidd LIMIT 2');
$stmt->execute(array(':uidd'=>$id));
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
$video_id = $row["categoria"];
?>
<div class="col-md-4 portfolio-item">
<a href="#">
<img class="img-responsive" width="700" height="400" src="user_images/<?php echo $row['img']; ?>" alt="" >
</a>
<h3>
<a href="#"><?php echo $row['nombre']; ?></a>
</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam viverra euismod odio, gravida pellentesque urna varius vitae.</p>
</div>
<?php
}
?>
<tr id="remove_row">
<td><button type="button" name="btn_more" data-vid="<?php echo $video_id; ?>" id="btn_more" class="btn btn-success form-control">More</button></td>
</tr>
<?php
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> NO HAY PUBLICACIONES ...
</div>
</div>
<?php
}
}
?>
</div>
<hr>
<!-- Footer -->
<footer>
<div class="row">
<div class="col-lg-12">
<p>Copyright © PhCoAviSos.CoM 2017 by AiPaT</p>
</div>
</div>
<!-- /.row -->
</footer>
</div>
<!-- /.container -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<script type="text/javascript"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<!-- Scroll -->
<script>
$(document).ready(function(){
$(document).on('click', '#btn_more', function(){
var last_video_id = $(this).data("vid");
$('#btn_more').html("Loading...");
$.ajax({
url:"2.php",
method:"POST",
data:{last_video_id:last_video_id},
dataType:"text",
success:function(data)
{
if(data != '')
{
$('#remove_row').remove();
$('#load_data_table').append(data);
}
else
{
$('#btn_more').html("No Hay mas publicaciones");
}
}
});
});
});
</script>
2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
$output = '';
$video_id = '';
sleep(1);
$connect = mysqli_connect("localhost", "root", "", "avisos");
$sql = "SELECT * FROM tbl_public WHERE categoria > ".$_POST['last_video_id']." LIMIT 3";
$result = mysqli_query($connect, $sql);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$video_id = $row["ai"];
$output .= '
<div class="col-md-4 portfolio-item">
<a href="#">
<img class="img-responsive" width="700" height="400" src="user_images/<?php echo $row['img']; ?>" alt="" >
</a>
<h3>
<a href="#">'.$row["nombre"].'</a>
</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam viverra euismod odio, gravida pellentesque urna varius vitae.</p>
</div>';
}
$output .= '
<tr id="remove_row">
<td><button type="button" name="btn_more" data-vid="'. $video_id .'"id="btn_more" class="btn btn-success form-control">More</button></td>
</tr>
';
echo $output;
}
?>
saludos y muchas gracias.
Valora esta pregunta


0