tommy445 Posted March 22, 2009 Share Posted March 22, 2009 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 https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/ Share on other sites More sharing options...
tommy445 Posted March 22, 2009 Author Share Posted March 22, 2009 to be clear, I am only interested in the No. column. 1. 2. 3. and so on. I'm surprised this seems to be difficult. Please suggest an alternative. thanks. Link to comment https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790619 Share on other sites More sharing options...
tommy445 Posted March 22, 2009 Author Share Posted March 22, 2009 O.K. if no one is able to figure it out, would someone please just explain the problem and if I should go in another direction. Please ??? Thanks. Link to comment https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790638 Share on other sites More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 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 https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790642 Share on other sites More sharing options...
Floydian Posted March 22, 2009 Share Posted March 22, 2009 It's not a hard problem lol... I'd use something like // init a variable: $count = 1; while (...............) { echo $count; $count++; } Hope that helps... Link to comment https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790643 Share on other sites More sharing options...
Philip Posted March 22, 2009 Share Posted March 22, 2009 Technically, isn't the OP already doing that, and just needs to echo $i? Link to comment https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790644 Share on other sites More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 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 https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790646 Share on other sites More sharing options...
Floydian Posted March 22, 2009 Share Posted March 22, 2009 lol KingPhilip, tis true, but I was trying to refrain from pointing out the obvious oversight... Link to comment https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790661 Share on other sites More sharing options...
Philip Posted March 22, 2009 Share Posted March 22, 2009 Hahaha, it's cool man Link to comment https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790663 Share on other sites More sharing options...
tommy445 Posted March 22, 2009 Author Share Posted March 22, 2009 Thanks, you all are great. It is funny, I had it in the bank, just forgot to take it out! Thanks again. Link to comment https://forums.phpfreaks.com/topic/150519-solved-display-row-number-column-not-mysql-row-number/#findComment-790690 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.