Well, it's quite simple I suppose, but the point is that I want to count the database records, in this case I have 2 in the DB, and when I put the foreach
and see it in the table it shows me the 2 records but with the number 2, when it should be 1,2,3,4... consecutive... in this example it should show me 1,2...
The table with 2 records
The foreach in PHP :/
foreach($usuarios as $key => $value){
echo '<tr>
<td>'.count($usuarios).'</td>
<td>'.$value["nombres"].'</td>
<td>'.$value["apellidos"].'</td>
<td>'.$value["correo"].'</td>
<td>'.$value["usuario"].'</td>';
Yes, it's quite simple, you can get the index of the loop in the following way:
Another option is that you define an incrementable variable, and only show it where you need it:
I hope I've helped. Luck!
if it is an indexed array this would work perfectly because the variable
$key
carries the indexone way is like this:
I hope it helps you... tell me!