I have spent all day but still can't figure out how to make load more button with jquery which will change value of variable in my php script, start my for loop and load more photos from my photos folder. My Jquery script is:
$(document).ready(function() {
$("button").click(function(){
$("php").attr({
"$b" : "16"
});
});
});
My php code is:
$charnum = strlen($file);
$b = 8;
$directory = "resource/galery/";
if (is_dir($directory)) {
if ($dh = opendir($directory)) {
for ($i = 0; ($file = readdir($dh)) && $i < $b; ++$i) {
if($file !="." && $file!=".."){
echo '
<div class="img">
<a target="_blank" href="/resource/galery/'.$file.'">
<img class="img-responsive" src="/resource/galery/'.$file.'">
</a>
<div class="desc">'.substr($file, 0, $charnum - 4).'</div>
</div>';
}
}
closedir($dh);
}
}
I want to change $b from 8 to bigger number. Or maybe there is another way to do this. Thank you.