I'm trying to show a profile completeness bar on the users account and the progress bar is showing but it's not adding the number values in order to calculate the percentage of completed fields.
My shortened code is as follows:
<?php
$result = mysql_query("SELECT title,name,surname,identityno,gender FROM cic_candidates WHERE id='{$id}' LIMIT 1");
if (!$result) {
echo "Could not successfully run query " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while($row = mysql_fetch_assoc($result))
$maximumPoints = 100;
$point = 0;
{
if($row['title'] != '')
$point+=20;
if($row['name'] != '')
$point+=20;
if($row['surname'] != '')
$point+=20;
if($row['identityno'] != '')
$point+=20;
if($row['gender'] != '')
$point+=20;
}
$percentage = ($point*$maximumPoints)/100;
echo $percentage."%";
?>
The percentage shows in the echo but the total is wrong at 0% - it's not taking the values of 20 points for each field that is completed and including them in the "addition" part of the percentage calculation. Please can you tell me where I'm going wrong - I've been trying to figure this out for 4 days and have googled this and read over 2000 forums but can't find the answer. Any help would be greatly appreciated.