So it's actually hard to explain what I mean.
So I have this list here. Its pulls data from the db and then displays it in a DIV on my webpage.
I want it to only show the first 4 listing. Then after 4 seconds. I want it to show the next 4 listening and keep revolving like that infinitely. If someone could point me in the direction to be able to do that. Also, It needs to be updating dynamically every 4 seconds. Not when the user hits refresh.
<?php session_start(); ?>
<head>
<link rel="stylesheet" type="text/css" href="tablecss.css">
<style type="text/css">
.extra {
position: relative;
top: 50px;
}
body {
overflow: hidden;
}
</style>
</head>
<body>
<?php
$con = mysqli_connect('##', '##', '##', '##');
if(mysqli_connect_errno()) {
echo 'Failed to Connect to MySQL' . mysqli_connect_errno();
}
$user = $_SESSION['username'];
$result = mysqli_query($con, "SELECT * FROM corporations");
echo "<table id='tb'border='1'>
<tr>
<th>Name</th>
<th>Owner</th>
<th>Last Price</th>
<th>Volume</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['name']. "</td>";
echo "<br>";
echo "<td>" . $row['owner'] . "</td>";
echo "<br>";
echo "<td>" .'$'. $row['shareValue'] . "</td>";
echo "<br>";
echo "<td>" . $row['publicShares'] . "</td>";
echo "<br>";
}
mysqli_close($con);
?>
</div>
</body>
What you can do is javascript, and use ajax. to load it every four seconds you can use setInterval( http://www.w3schools.com/jsref/met_win_setinterval.asp ), but for me its better if you use jQuery load more data on scroll .
to limit output use the limit of mysql.
see this article: http://www.mysqltutorial.org/mysql-limit.aspx
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.