Reputation: 299
while ($one = mysql_fetch_array($two)) {
<td>Want Serial No Here</td>
<td><?=$something['something']?></td>
}
I want to autonumber Serial No. .. is it possible?
Upvotes: 0
Views: 1848
Reputation: 146490
I have the impression that you are trying to generate a consecutive number for each row:
<?php
$count = 0;
while($row = mysql_fetch_assoc($res)){
$count++;
echo '<tr><td>' . $count . '</td><td>' . htmlspecialchars($row['name']) . '</td></tr>';
}
Upvotes: 2
Reputation: 425623
MySQL
does not support rownum
/ row_number
natively.
You could emulate it using session variables:
SET @r := 0;
SELECT @r := @r + 1 AS rownum, t.*
FROM mytable
ORDER BY
myfield
, or better, just use a PHP
variable:
<?
$i = 0;
while ($row = mysql_fetch_assoc($res)) { ?>
<td><?= ++$i ?></td>
<td><?=$row['serial_no']?></td>
<? } ?>
Upvotes: 1