melloorr Posted August 30, 2011 Share Posted August 30, 2011 Hello, sorry if I do not explain this well but I am wondering if there is some code that allows me to search a database for a username, and counts how many times the username is in the database, then displays the total amount on-screen Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/ Share on other sites More sharing options...
voip03 Posted August 30, 2011 Share Posted August 30, 2011 you can use mysql_num_rows() http://php.net/manual/en/function.mysql-num-rows.php http://www.plus2net.com/sql_tutorial/mysql_num_rows.php mysql count() http://www.tizag.com/mysqlTutorial/mysqlcount.php if you google it mysql_num_rows vs count Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/#findComment-1263683 Share on other sites More sharing options...
Philip Posted August 30, 2011 Share Posted August 30, 2011 IMO count is the way to go. Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/#findComment-1263717 Share on other sites More sharing options...
Pikachu2000 Posted August 30, 2011 Share Posted August 30, 2011 As a general rule, if you need to run a SELECT query to get data that you're going to use for something, and you also need the count, use mysql_num_rows(). If all you need is a count and no other data, use a SELECT COUNT() query. Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/#findComment-1263725 Share on other sites More sharing options...
melloorr Posted August 31, 2011 Author Share Posted August 31, 2011 Thanks for the help everyone, but it will be too hard to implement it so I am giving up for now. But I plan on Learning PHP and SQL properly soon, so you may see more of me here Thanks again! Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/#findComment-1263896 Share on other sites More sharing options...
fenway Posted September 1, 2011 Share Posted September 1, 2011 Thanks for the help everyone, but it will be too hard to implement it so I am giving up for now. But I plan on Learning PHP and SQL properly soon, so you may see more of me here Thanks again! What's too hard to implement -- one query? Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/#findComment-1264308 Share on other sites More sharing options...
melloorr Posted September 4, 2011 Author Share Posted September 4, 2011 What's too hard to implement -- one query? Yeah, I am using pbpbb so it will also mean would having to find the username without actually typing it in. (too complicated for me to understand) Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/#findComment-1265350 Share on other sites More sharing options...
fenway Posted September 4, 2011 Share Posted September 4, 2011 What's too hard to implement -- one query? Yeah, I am using pbpbb so it will also mean would having to find the username without actually typing it in. (too complicated for me to understand) I don't know what that means. Link to comment https://forums.phpfreaks.com/topic/246059-count-a-phrase-in-sql/#findComment-1265468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.