Numbering Each Data Row
Numbering Each Data Row
Hey guys,
I'm working on a project that I implemented DataTables into and it's a table of a bunch of players for a video game from a MySQL database. Anyways- I have it sorting by a certain column from the database, but I'd like to give a rank or number to each row. So like the first row would be ranked 1, and it would increase by 1 for each new row. The thing is... I don't know how well it would work when searching for someone with the dynamic feature.
I'm not sure if any of that was comprehendible but I'm not sure how else I can word it. Here's the table itself http://honedge.com/crown/ladder.php - I just need to create another column in the table called "Rank".
Any help would be greatly appreciated!
I'm working on a project that I implemented DataTables into and it's a table of a bunch of players for a video game from a MySQL database. Anyways- I have it sorting by a certain column from the database, but I'd like to give a rank or number to each row. So like the first row would be ranked 1, and it would increase by 1 for each new row. The thing is... I don't know how well it would work when searching for someone with the dynamic feature.
I'm not sure if any of that was comprehendible but I'm not sure how else I can word it. Here's the table itself http://honedge.com/crown/ladder.php - I just need to create another column in the table called "Rank".
Any help would be greatly appreciated!
This discussion has been closed.
Replies
http://datatables.net/usage/columns
// Using aoColumnDefs
$(document).ready(function() {
$('#example').dataTable( {
"aoColumnDefs": [
{
"fnRender": function ( o, val ) {
return o.aData[0] +' '+ o.aData[3];
},
"aTargets": [ 0 ]
}
]
} );
} );
[/code]
Here's the example for the combo you mentioned. I guess i'm a bit nooby at this. The way I used to echo all of the data was a foreach so I just set $i = 0 then echo'd $i+1. Not sure how to really accomplish this here :/