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 Link to comment https://forums.phpfreaks.com/topic/179161-need-a-fuction-to-count-entries-in-a-field/ 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? Link to comment https://forums.phpfreaks.com/topic/179161-need-a-fuction-to-count-entries-in-a-field/#findComment-945216 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 Link to comment https://forums.phpfreaks.com/topic/179161-need-a-fuction-to-count-entries-in-a-field/#findComment-945235 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 Link to comment https://forums.phpfreaks.com/topic/179161-need-a-fuction-to-count-entries-in-a-field/#findComment-945240 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']; Link to comment https://forums.phpfreaks.com/topic/179161-need-a-fuction-to-count-entries-in-a-field/#findComment-945249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.