merck_delmoro Posted May 6, 2009 Share Posted May 6, 2009 Example Record in the DataBase: Cat Dog Mouse I want to output : The Dog is Located at # 2 Quote Link to comment Share on other sites More sharing options...
taith Posted May 6, 2009 Share Posted May 6, 2009 easiest way is to put an auto_increase'ing number in your table... basically every entery takes the next sequencial number... Quote Link to comment Share on other sites More sharing options...
merck_delmoro Posted May 6, 2009 Author Share Posted May 6, 2009 I've done it by my self haha this is the code I've made $query=mysql_query("SELECT * FROM animals"); while($row = mysql_fetch_array($query) and $row['animal'] !="dog") { $count+=1; } echo print "The Dog is Located at # ".$count+1; Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Does animals have an ID field? Simpler and faster: $result = mysql_query("SELECT id FROM animals WHERE animal = 'dog' LIMIT 1"); $row = mysql_fetch_assoc($result); echo $row['id']; Quote Link to comment 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.