Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.