Jump to content

Need a fuction to count entries in a field


JamesThePanda

Recommended Posts

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

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'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.