0

I have the following code and need to not display decimals...

I'm unsure where to add a round() function...

<?php
                            $nmdwiid = $row_eLearningSuite['nmdwiid'];
                                                    
                            $sql = "SELECT COUNT(*) AS total FROM eLearningSuiteProduct"; 
                            $query = mysql_query($sql);
                            $recordset = mysql_fetch_assoc($query);
                            $count = $recordset["total"];
                            echo $nmdwiid/$count * 100;
                        ?>

Any help would be great!
Ted

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by changeco
0

Depending on what variable you want to round. If you are trying to round $count you can do something like:

echo(round($count));

if you want to round the last echo line you can assign everything to a variable then round it and echo it like this:

$rounded = $nmdwiid/$count * 100;
echo (round($rounded));

And that should output the total already rounded. (in case you are wondering, there's a second parameter to the rounded function with which you can specify the number of decimal places you want to round to, but it's optional so you don't have to use it)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.