Jump to content

Retrieving Data From Multiple Tables


Icebergness

Recommended Posts

Hi,

 

I work in a Stockbroker's and I'm trying to display our client's holdings from my MSSQL Database. To put it in to perspective...

 

The page displays a single client. A client has multiple holdings. Each holding relates to a single stock, and each stock is linked to a single currency.

 

So what I need is something like:

 

Bob Marley's Holdings

 

Holding 1: Apple | USD | 1.6549

Holding 2: Google | EUR | 1.2525

 

The code I have so far is:

<?php

$client_ref = "50000";

$holding_sql = "SELECT * FROM [HOL_CORE] INNER JOIN [sTO_CORE] on [HOL_CORE].[sTOCK REC NO] = [sTO_CORE].[sTOCK ID] WHERE [HOL_CORE].[CLIENT REC NO] = '$client_ref' AND [HOL_CORE].[QTY HELD] != '0'";
$holding_result = sqlsrv_query($connnection, $holding_sql);
while($holding = sqlsrv_fetch_array($holding_result, SQLSRV_FETCH_ASSOC))

{

    $stock_currency = $holding['CURRENCY'];
 $stock_name = $holding['SHORT NAME'];

 echo $stock_name . ' | ' . $stock_currency . ' | ' . '<br>';

}

?>

 

Now I need to get the exchange rate from a table called [CUR_CORE] for each stock, where [CURRENCY ABBREV] = $stock_currency. Does anyone know how I would go about retrieving this?

 

Cheers!

 

Dave

Link to comment
Share on other sites

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.