RLAArtistry Posted September 4, 2012 Author Share Posted September 4, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/267793-echo-php-variable-from-database/page/2/#findComment-1375048 Share on other sites More sharing options...
RLAArtistry Posted September 4, 2012 Author Share Posted September 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/267793-echo-php-variable-from-database/page/2/#findComment-1375059 Share on other sites More sharing options...
Christian F. Posted September 4, 2012 Share Posted September 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/267793-echo-php-variable-from-database/page/2/#findComment-1375131 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.