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

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)

PERFECT... the 2nd one works perfectly!

thanks @asaenz

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.