Jump to content

echo php variable from database


RLAArtistry

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.

Archived

This topic is now archived and is closed to further replies.

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