merck_delmoro Posted May 5, 2009 Share Posted May 5, 2009 example: Animal Dog Cat Mouse The output must be the Dog is on the 1 position The Cat is on the 2nd Position and Mouse is on the 3rd Position Quote Link to comment https://forums.phpfreaks.com/topic/157010-q-how-to-find-the-position-of-the-record-on-the-database-record/ Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Does this table have a unique ID field? Though you can already keep track of positioning in a while loop going through the entries. Quote Link to comment https://forums.phpfreaks.com/topic/157010-q-how-to-find-the-position-of-the-record-on-the-database-record/#findComment-827089 Share on other sites More sharing options...
ratcateme Posted May 6, 2009 Share Posted May 6, 2009 you could do a query and output like this $result = mysql_query("SELECT Animal FROM animals") or die(mysql_error()); for($i = 1;$row = mysql_fetch_array($result)!=null;$i++){ echo $row['Animal'] . " is at " . $i; } this uses a for instead of a while so you don't need a ID key although i would recommend putting one in Scott. Quote Link to comment https://forums.phpfreaks.com/topic/157010-q-how-to-find-the-position-of-the-record-on-the-database-record/#findComment-827091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.