Jump to content

[SOLVED] Display row number column - NOT mysql row number


tommy445

Recommended Posts

i am trying to display a column with numbers 1 through end of results.

 

my code is displaying the record row number from mysql (not what i want)

 

Any Ideas.  Thanks.

 

<?php ....connect info....query info.....

 

$num=mysql_numrows($result);

 

mysql_close();

?>

<table border="0" cellspacing="2" cellpadding="2">

<tr>

<th><font face="Arial, Helvetica, sans-serif">No.</font></th>

<th><font face="Arial, Helvetica, sans-serif">Borrower</font></th>

<th><font face="Arial, Helvetica, sans-serif">Case Number</font></th>

</tr>

 

<?php

$i=0;

while ($i < $num) {

 

$f1=mysql_result($result,$i);

$f2=mysql_result($result,$i,"client_name");

$f3=mysql_result($result,$i,"client_id");

?>

 

<tr>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>

</tr>

 

<?php

$i++;

}

?>

 

The display should be:

 

No.    Borrower      Case Code

1.      John Doe      15

2.      Mary Jane    16

3....and so on

to be clear, I am only interested in the No. column. 1. 2. 3. and so on.

 

I'm confused...  Number column from where?  If you're referring to the database table itself then you most likely have an auto-increment field that you can select in the query.

 

If you're referring to the column number for the actual HTML output, then use $i rather then $f1:

 


 

Other than that I don't really know what column you're inquiring about.

Technically, isn't the OP already doing that, and just needs to echo $i? ;)

 

Yeah he is definitely already doing that.  Like KingPhilip said, he just needs to echo $i in the table row but increment it before he echos it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.