I have a table with 15 Columns ID
, USERNAME
, PASSWORD
, EMAIL
, TELEPHONE
, FAX
, ADDRESS
, COUNTRY
, CITY
, NATIONALITY
, EDUCATION
, etc in mysql database.
There is some required fields and optional fields. Users will fill the required fields and some optional fields. I need to give every user completeness score (e.g. Completeness Score 40%
) to increase there attention to fill all optional fields.
How can I do that in PHP? I've tried to do it by ( SELECT COUNT WHERE ) - but without any result.
Supposed the table is called "users", you do
SQL: 'select * from users where id=X'
(Without adding any of the optional fields in the WHERE clause!)
Then later in PHP, you do something like this:
if (strlen($row['username'])>1)
$score += 10;
if (is_valid_email($row['email']))
$score += 10;
... et cetera. There might be better ways of doing this. It is just to give you an Idea! This is a very basic question, you might want to learn some more! Cheers.