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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.