JamesThePanda Posted October 27, 2009 Share Posted October 27, 2009 Hi I need a fuction to count how many times a email address is entered in to a field. I making a for wordpress that counts how many timesa user has made comments. Thanks James Quote Link to comment Share on other sites More sharing options...
trq Posted October 27, 2009 Share Posted October 27, 2009 Were not exactly here to write code for people. Where exactly are you stuck? Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted October 27, 2009 Author Share Posted October 27, 2009 Sorry Im a complete nuub to php. I watched some vids, and I can connect to a database but what is the php funtion to count something in a field. Basically I want to make a form, then when I type in a email address it counts how many comments have been made by a particular email address. This is more of just a learning exercise. Thanks James Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted October 27, 2009 Author Share Posted October 27, 2009 basically in short my question is what is the php function to count a variable, within a mysql field. Thanks James Quote Link to comment Share on other sites More sharing options...
cags Posted October 27, 2009 Share Posted October 27, 2009 If you are attempting to count how many rows in a database contain a specific e-mail in a predetermined column then you could do something like so... $sql = "SELECT COUNT(email) AS email_count FROM table WHERE email='$email'"; $result = mysql_query($sql) or trigger_error("SQL: $sql, ERROR: " . mysql_error(), E_USER_ERROR); $row = mysql_fetch_assoc($result); $count = $row['email_count']; 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.