herghost Posted October 24, 2009 Share Posted October 24, 2009 Hi all, I have this: <?php session_start(); include('../common/dbconnect.php'); $stock_id = $_GET['stock_id']; //get stocks rows $query = "SELECT * FROM stocks WHERE stock_id = '$stock_id'"; $result = mysql_query($query, $conn) or die(mysql_error($conn)); $row = mysql_fetch_array($result); extract($row); mysql_free_result($result); //get bank balance $query1 = "SELECT bank FROM users_stocks WHERE user_id = '" . $_SESSION['user_id'] ."'"; $result1 = mysql_query($query1, $conn) or die(mysql_error($conn)); $rows = mysql_fetch_array($result1); extract($rows); mysql_free_result($result1); //define variable $t_val = $row['t_val']; $sc = $row['stock_code']; $name = $row['stock_name']; $bank = $rows['bank']; $max = $bank / $t_val; echo "Each share of $sc is currently worth $$t_val, you have $$bank available in the bank to spend on shares and you can buy a maximum of $max in $name today"; ?> However the result of $max is vary rarely a whole number! How can I get this rounded down to no decimal points? (whole number only) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/178828-solved-display-number-with-no-decimal-place/ Share on other sites More sharing options...
severndigital Posted October 24, 2009 Share Posted October 24, 2009 http://us3.php.net/manual/en/function.floor.php Quote Link to comment https://forums.phpfreaks.com/topic/178828-solved-display-number-with-no-decimal-place/#findComment-943402 Share on other sites More sharing options...
herghost Posted October 24, 2009 Author Share Posted October 24, 2009 Perfect Thanks! $max = floor($bank / $t_val); Quote Link to comment https://forums.phpfreaks.com/topic/178828-solved-display-number-with-no-decimal-place/#findComment-943405 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.