jason97673 Posted August 6, 2008 Share Posted August 6, 2008 Not sure of the exact terminology for this, but I have a set of data in the database. About ten or so records are returned. I want the first row to display 1. ---Data returned 2. ---Data returned etc I know this involves a loop just unsure how to do this. Thanks. Link to comment https://forums.phpfreaks.com/topic/118390-php-rankings/ Share on other sites More sharing options...
ratcateme Posted August 6, 2008 Share Posted August 6, 2008 this is how you would do it using mysql it should be similare with what ever database you have while($row = mysql_fetch_assoc($result)){ echo $row['field_name']; echo $row['filed_2']; } Link to comment https://forums.phpfreaks.com/topic/118390-php-rankings/#findComment-609268 Share on other sites More sharing options...
jason97673 Posted August 6, 2008 Author Share Posted August 6, 2008 Eh well actually I have something similar to this. This is my code while($row = mysql_fetch_array($data)) { echo '<tr><td><a href="/data/profile.php?profileID=' .$row['id'] .'">' .$row['first'] .' ' .$row['last'] .'</a></td>'; echo '<td>' .$row['cmp'] .'</td>'; echo '<td>' .$row['att'] .'</td>'; echo '<td>' .$row['cmppct'] .'%</td>'; echo '<td>' .$row['yards'] .'</td>'; echo '<td>' .$row['ypa'] .'</td>'; echo '<td>' .$row['td'] .'</td>'; echo '<td>' .$row['tdpct'] .'%</td>'; echo '<td>' .$row['interceptions'] .'</td>'; echo '<td>' .$row['intpct'] .'%</td>'; echo '<td>' .$row['rating'] .'</td></tr>'; } But I actually want each of the results returned to display the actual NUMBER such as 1, 2, 3, etc. Link to comment https://forums.phpfreaks.com/topic/118390-php-rankings/#findComment-609272 Share on other sites More sharing options...
secoxxx Posted August 6, 2008 Share Posted August 6, 2008 try <ol> <?php while($row = mysql_fetch_array($data)) { echo '<li>'; echo '<tr><td><a href="/data/profile.php?profileID=' .$row['id'] .'">' .$row['first'] .' ' .$row['last'] .'</a></td>'; echo '<td>' .$row['cmp'] .'</td>'; echo '<td>' .$row['att'] .'</td>'; echo '<td>' .$row['cmppct'] .'%</td>'; echo '<td>' .$row['yards'] .'</td>'; echo '<td>' .$row['ypa'] .'</td>'; echo '<td>' .$row['td'] .'</td>'; echo '<td>' .$row['tdpct'] .'%</td>'; echo '<td>' .$row['interceptions'] .'</td>'; echo '<td>' .$row['intpct'] .'%</td>'; echo '<td>' .$row['rating'] .'</td></tr>'; echo '</li>'; } ?> </ol> Link to comment https://forums.phpfreaks.com/topic/118390-php-rankings/#findComment-609274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.