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
Post a Comment