0
There is a table that shows all BD records, but on a page of my project where I should show the record total(id) of my table.
Connection file:
<?php
$mysqli = new mysqli("localhost", "house863_teste", "teste", "house863_registro");
if ($mysqli->connect_errno) {
echo "Falha ao conectar com o mysql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}?>
File that brings data to HTML table:
<?php
require_once("config.php");
$query = "SELECT * FROM lista ";
$result = mysqli_query($mysqli, $query);
$x=1;
while($row = mysqli_fetch_assoc($result))
{
echo("
<tr>
<td class=\"n\">".$row['id']."</td>
<td class=\"nm\">".$row['nome']."</td>
<td><span class=\"cont\" id=\"s".$x."\" inicial=\"".$row['tempo']."\"></span></td>
<td class=\"qp\">".$row['pm']."</td>
<td class=\"sm\">".$row['dific']."</td>
<td class=\"op\">".$row['op']."</td>
<td class=\"btnt\"><button class=\"btn1\" onclick=\"dispara('s".$x."')\"><a target=\"_blank\" href=\"".$row['link']."\">Clique aqui</a></button></td>
</tr>");
$x=$x+1;
}
echo("</tbody>");
?>
After making the connection, as I can show on the page the total of id
's registered?
Html example:
Total de registros(<?php require_once("total.php");?>)
Could explain the code?
– gato
Of course, mysqli_num_rows($result); will return the number of rows in the "$result" query, this number will be played inside the "$total" variable and the <?php echo $total ? > will write on tele the number.
– Leone Henrique
Leone edits and puts in response.
– gato