My script is supposed to display the first 10 images in the MySQL database and have the script hide the rest of the users images until the user clicks the link <a href="#">View All</a>
and have the rest of the images slide down when the user clicks the link.
My Question: So my question is that my images won't display when the user clicks the link <a href="#">View All</a>
and I was wondering how can I fix this problem so that all my users images are displayed when the user clicks the link?
PHP & MySQL code.
$multiple = FALSE;
$row_count = 0;
$dbc = mysqli_query($mysqli, "SELECT * FROM images WHERE images.user_id = '$user_id'");
if (!$dbc) {
print mysqli_error($mysqli);
} else {
echo '<div id="images">';
while ($row = mysqli_fetch_array($dbc)) {
if (($row_count % 5) == 0) {
echo '<ul>';
}
echo '<li><img src="/images/thumbs/' . $row['url'] . '" /></li>';
if (($row_count % 5) == 4) {
$multiple = TRUE;
echo '</ul>';
} else {
$multiple = FALSE;
}
$row_count++;
}
if ($multiple == FALSE) {
echo '</ul>';
}
if ($row_count == 5) {
echo '</div>';
echo '<div id="hidden">';
}
}
echo '</div>';
echo '<a href="#" id="view_all">View All</a>';
JQuery code.
$(document).ready(function(){
$("#hidden").hide();
$("#view_all").click(function(){
$("#hidden").slideDown();
});
});
Here is the HTML code
<div id="images">
<ul>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
</ul>
<ul>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
<li><img src="../images/image.png" /></li>
</ul>
</div><div id="hidden"></div>
<a href="#" id="view_all">View All</a>