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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.