php - How to increment a number inside foreach loop? -


i want fetch data database , show in form of html table.

i want first column of table show number of row 1,2,3,4...

this foreach loop

$i=0;     foreach($sql $sql)     {     echo "<tr>";         echo "<td>$i++</td>";         echo "<td>$sql->jobseeker_name</td>";         echo "<td>$sql->jobseeker_phone</td>";         echo "<td>$sql->login_email</td>";     echo "</tr>"; } 

it not working , don't know wrong it.

don't write $i++where want echo. echo first , @ end of loop, add $i++ incement value:

<?php      $i = 1;      foreach ($sql $sql) {     echo "<tr>";     echo "<td>$i</td>";     echo "<td>$sql->jobseeker_name</td>";     echo "<td>$sql->jobseeker_phone</td>";     echo "<td>$sql->login_email</td>";     echo "</tr>";      $i++; } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -