Jump to content

Recommended Posts

Hey ChristianF,

Does this means I have to create a column name percent?

 

Notice: Use of undefined constant percent - assumed 'percent' in D:\hosting\8594549\html\customercenter\Survey\survey_ratings.php on line 20
70.0000

 

How do I remove the .0000?

I got it!!!

 

Thank you very much ChristianF. You have been extremely helpful and informative. I definitely will start coding better thanks to your tips.

 

I will still hang around on this site, maybe I can help someone with my CSS and design know-hows one day.

 

Here is the final code

$newSQL = mysql_query("SELECT (SELECT COUNT(*) FROM survey1 WHERE Q3=1 OR Q3=2) / (SELECT COUNT(*) FROM survey1) * 100 AS `percent`");
$sqlpercent = mysql_result($newSQL,0);
$satrate = number_format($sqlpercent, 0,'','');
echo "$satrate %";

If something is off please let me know.

 

Thank you again.

Good to hear that you got it, and I'm glad I could help. :)

 

The code looks good, and I can't see anything off. The only thing is a very minor nitpick, in that intval () would have done the job just as well as number_format () in this case. Not something worth changing, in other words.

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.