Reputation: 23
I need some advice. I am creating a PHP website which has like 20 table to show from the database.
I using while loop to generate 20 table and populate the data inside and no problem.
But what I want to do is create a specific size div1 lets say 520 w x 520px h. Then using loop I generate first table with data and display then that table moving up slowly until it disappear from div1 and i continue this for rest of the table.
Anyone can help on logic here or point me to a resource which can help me do it.
Upvotes: 0
Views: 64
Reputation: 118
You mean an animation? Then it is a JS/CSS job. PHP is server-side, and the elements that you see in a webpage are downloaded from the server. JS and CSS work on client-side,as well as HTML. So if you want to make an animation, you should start by making a JS function that repeats itself for n times. In that loop, just edit the divs' styles and that's it.
If you don't know how to do that, here is the code:
var inter = setInterval(animate,20);
var i = 0;
function animate(){
document.getElementById("div1").style.marginBottom = i+"px";//This will make the div go up if your div id is div1. If not, just change div1 for your id. If you want to move it down, you would have to replace marginBottom for marginTop(this will only work if your div's position is relative).
i++;
if(i==200){//When it has moved 200px, it will stop
clearInterval(inter);
}
}
NOTE: the code above is an example. If you want it to move left/right/down or that it moves 500px instead of 200px, you would have to change it. Guide yourself with the comments
Upvotes: 1