简体   繁体   中英

PHP Display Mysqli data

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 wx 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM