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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Philip Posted August 30, 2011 Share Posted August 30, 2011 IMO count is the way to go. Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment 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? Quote Link to comment 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) Quote Link to comment 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. 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.