Jump to content

[SOLVED] Display number with no decimal place


herghost

Recommended Posts

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

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.