Pages in tables

1

How can you make this table when it is filled by showing "page" 10 lines, and when you pass those 10 lines, you have to make another page, and put a search engine.

I find it hard to do all this because I'm new, and I'm trying to learn.

And it would happen to be this.

Current code:

<?php
	require('conexion.php');
	
	$query="SELECT *  FROM umg511_tbl";

	$resultado=$mysqli->query($query);
	
?>
<html>
	<head>
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600' rel='stylesheet' type='text/css'>
		<link href="style/style.css" rel="stylesheet" charset=UTF-8>
		<title>En Desarrollo</title>
	</head>
    <body>
	
		<ul>
			<li class="imagenes"><a href="index.html"><img src="img/logo.png" class="imagenes" /></a></li>
			<li><a href="index.html">Home</a></li>
			<li><a href="ip.php">Direccion</a></li>
			<li><a href="#">Datos</a></li>
		</ul>
		<div class="datos">
		
		<table>
	<thead>
		<tr class="centro">
			<td>ID</td>
			<td>Dia</td>
			<td>Descargar</td>
				</tr>
				<tbody>
					<?php while($row=$resultado->fetch_assoc()){ ?>
						<tr>
							<td name="id">
								<center> <?php echo $row['umg511_id']; ?> </center>
							</td>
							<td name="fecha">
								<center><?php echo $row['umg511_day'];?></center>
							</td>
							<td name="descargar">
								<form action="export.php" method="post" id="enviar">
									<input name="idOculto" id="idOculto" type="hidden" value="<?php echo $row['umg511_id']; ?>" />
									<center><input type="submit" value="Descargar" /></center>
								</form>
							</td>
						</tr>
					<?php } ?>
				</tbody>
</table>	

		
		</div>
		<div class="copy">
			<a>©Created only for ...</a>
		</div>
	</body>
</html>

And if you add many entries, this happens:

    
asked by Pepe Flanco 25.05.2017 в 13:19
source

1 answer

1

The trick is to use the LIMIT clause of MySql, example:

mysql_query("SELECT * FROM table LIMIT 3")

This option allows you to obtain only the first 3 records, then:

$fetch = mysql_query("SELECT * FROM table LIMIT 0, 10")

Allows you to get 10 records from register 0 Are you catching the trick?

Now with a variable:

$fetch = mysql_query("SELECT * FROM table LIMIT $startrow, 10")

where $stratrow should be increased by 10 in each click on "next page" so you will get the first 10 records, then the next 10 and so you can go paging your results.

SOURCE: link

    
answered by 25.05.2017 / 14:09
source