$userid = $_SESSION[userid]
$sqll = mysql_query("SELECT count(id) FROM entries WHERE userid='$userid'");
Is using count(id) efficient? Or is there a better way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
count(*)should do.Make sure you escape
$userid, though.Edit: just half-a-word of explanation.
count(column)counts all rows for whichcolumnis not null. Using*is supposed to be the most efficient way of counting rows regardless of content and more descriptive in case someone (including yourself) is ever going to (re)read the code.