I have a working JavaScript that refreshes a different image every minute, based on the time of the day. The script takes the images from a folder that contains files named after every single minute... eg: 0435.jpg (if 4:35 am).
What I want to do is update the following js to make it able to pull these images from a database, since they were uploaded along other info (name, comment, city) stored in a db... I want the pics to display next to this info.
<img id="myImg" class="round" alt="This is the time" src="minute/default.jpg" />
<script type="text/javascript">
setInterval(function() {
var myImg = document.getElementById('myImg');
myImg.src = '/minute/' + new Date().toTimeString().substring(0, 5).replace(':', '') + '.jpg' ;
onerror = myImg.src = '/minute/default.jpg' ;
}, 30000);
</script>
I don't know how to approach this situation. I am a newbie in JavaScript.