Jump to content

Icebergness

Members
  • Posts

    30
  • Joined

  • Last visited

About Icebergness

  • Birthday 12/11/1986

Profile Information

  • Gender
    Male
  • Location
    Blackpool, UK

Icebergness's Achievements

Member

Member (2/5)

0

Reputation

  1. And the PHP file that the script is calling, just in case it matters <!doctype html> <html> <head> <meta charset="utf-8"> <title>Transactions</title> </head> <body> <h1>Transactions</h1> <div id="content"> <?php $client=$_GET["client"]; $stock=$_GET['stock']; $mssql_server= "sql-primary"; $mssql_database = "FOUR_I_CORE"; include("../index_files/mssql_include.php"); $sql_count = "SELECT * FROM [TRA_CORE] WHERE [CLIENT REC NO] = '$client' AND [sTOCK REC NO] = '$stock' AND [QUANTITY] != 0"; $stmt_count = sqlsrv_query($connnection, $sql_count); while($count = sqlsrv_fetch_array($stmt_count, SQLSRV_FETCH_ASSOC)) { $quantity = $count['QUANTITY']; $date = $count['EVENT DATE']; $cost = $count['COST/PROCEEDS']; $currency = $count['ORIGINAL CURRENCY']; echo $cost . '<br>'; } ?> </div> </body> </html>
  2. Hi, I'm trying to make a table that display a list of what stocks each client holds. In simple terms: Client 1 holdings: | + | Apple | | + | Google | | + | Microsoft | I currently have it set up so that if I click on the '+' (which is an image), it opens up a jQuery UI dialog box with static information in: <script> $(function() { $('div.dialog') .dialog( { autoOpen: false, modal: true } ); $('img.opener') .css("cursor","pointer") .click(function() { $('#' + this.id.replace(/opener/, 'dialog')) .dialog('open'); return false; } ); }); </script> ...and the table... <?php echo '<td><img id="opener' . $row_counter . '" class="opener" src="../images/procedural/plus-white.png" title="Click to show Transactions"></td>'; echo '<td align=left>' . $stock_sedol . '</td>'; echo '<td align=left>' . htmlentities($stock_short_name) . '</td>'; echo '<td><div href="trans.php?client=' . $client_ref . '&stock=' . $stock_id . '" id="dialog' . $row_counter . '" class="dialog" title="Transactions for ' . $stock_sedol . '">This is box ' . $row_counter . '</div></td>'; ?> Now I want to be able to populate the table with data from my SQL server, so I have the following code that I found on the internet (which works in isolation), but I'm not sure how to integrate it in to the above code. <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>jQuery UI Dialog - Animation</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.8.2.js"></script> <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#tire-specs th a').each(function() { var $link = $(this); var $dialog = $('<div></div>') .load($link.attr('href') + ' #content') .dialog({ autoOpen: false, title: $link.attr('title'), width: 600 }); $link.click(function() { $dialog.dialog('open'); return false; }); }); }); </script> </head><body> <table id="tire-specs"> <thead> <tr> <th>Size</th> <th><a href="trans.php?client=12345&stock=67890" title="Transactions">Transactions</a></th> <th>Max Load</th> <th>Max Inflation Pressure</th> <th>Tread Depth</th> </tr> </thead> <tbody> <tr> <td>205/65R15</td> <td>620 A A</td> <td>1477 lbs.</td> <td>44 psi</td> <td>11/32"</td> </tr> </tbody> </table> </body></html> Any help you could give would be much appreciated. Dave
  3. Either Google is getting worse, or I'm getting worse at using Google? (Probably the latter!) That worked perfectly. I'd read somewhere that multiple joins couldn't be done - obviously they can Thank you for your help!
  4. 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
  5. Hi Requinix, Thanks for clearing that up for me, makes a lot more sense to me now You understood me correctly, yes, and your suggestion worked perfectly, so thank you very much! You've saved me countless hours of smashing my head against a wall! Cheers, Dave
  6. Hi Requinix, Please forgive me, but I don't understand what you mean? Where do I need to remove/add quotes? Cheers, Dave
  7. Hi, This one has been doing my head in for hours!. I have a script that, to put it simply, inserts either NULL or a string in to a MySQL database. However, it's acting rather weird with different values. Here is my SQL script... <?php $sql = "INSERT INTO stocks (s_isin) VALUES ('$isin')"; mysql_query($sql); ?> And then the variables being fed in to it are... <?php if ($user_isin_dummy == "1") // ISIN is Dummy { $isin = "NULL"; } else // ISIN is live { $isin = $user_isin; } ?> In it's current state, the "else" clause works fine, but the "if" statement inserts the string "NULL" in to the database. If I remove the single quotes from "$isin" in the SQL code, the "else" works only if the string begins with a number. If it starts with a letter, it simply doesn't insert at all. However, the "if" now correctly inserts a null value. How can I make it so that a proper null value is inserted on the "if" statement, and also for any string to be inserted on the else clause? Cheers, Dave
  8. Sorry now that you've pointed the sub-forum out, I feel an idiot for missing it Thank you for your help this was exactly what I was looking for!
  9. Hi, I'm trying to extract a percentage from data sent through a form. In the below example, I'm trying to dig out the "5%" part, however, this can often be multiple digits, sometimes including decimals as well. Basically I need the numbers and decimals preceding the % symbol, so "5%", "123.456%" and so on. <?php $text = "Bob the builder 5% 17/05/12"; $n = preg_match_all('/ (.*?)%/s', $text, $match); if ($n) { $search=$match[0]; for ($k=0;$k<$n;$k++) { $accpay = $search[$k]; } } ?> This example gives me the result "the builder 5%". Does anyone know how I can further restrict this? It works fine if 5% is at the start of the string, but the string can be given in any order unfortunately. Cheers
  10. Barand, Thank you!! I'm still learning a lot of PHP and haven't dabbled in mktime yet. I'd looked at it, but wasn't sure how to use it, but that worked perfectly. I can sleep tonight!
  11. Hi, This one has been driving me up the wall, so hopefully some kind person can help me. I'm trying to make a validation script. $creststartdate comes in from a form as a UK formatted date (d/m/Y), and if $creststartdate is more than a month ahead of today, then it gets rejected. here's the code I have now... $today = date("m/d/y"); $onemonth = strtotime ('+1 month', strtotime($today)); $nextmonth = date ('d/m/Y', $onemonth); $csd = date("m/d/y", $creststartdate); $strcsd = strtotime($csd); $newdate = date ('d/m/Y', $strcsd); if ($newdate > $nextmonth) { $creststartdatefailed = "The Crest Start Date cannot be more than 1 month in the future."; $creststartdatevalid = "NO"; } As it stands, this version of the code means that nothing is getting rejected. Please help?? Cheers
  12. *facepalm* how stupid do I feel now? That solved it for me so thank you very much, you saved my bacon!
  13. Hi, I am trying to connect to our company software database via PHP. I've got the connection working and can retrieve records etc. However one of my tables has a ridiculous column name that I can't get working. Here's the code... $mssql_server = "sql-primary"; $connectionInfo = array( "Database"=>"FOUR_I_CORE", "UID"=>"...", "PWD"=>"..."); $connnection = sqlsrv_connect( $mssql_server, $connectionInfo); $sql = "SELECT [REF (SEDOL) No.] FROM [sTO_CORE] WHERE [REF (SEDOL) No.] = $sedol"; $stmt = sqlsrv_query( $connnection, $sql ); if( $stmt === false) { die( print_r( sqlsrv_errors(), true) ); } while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) { //echo '<b>Client Ref:</b> ' . $row['REF (SEDOL) No.'] . '<br>'; } I keep getting the following error message: Array ( [0] => Array ( [0] => 42S22 [sqlSTATE] => 42S22 [1] => 207 [code] => 207 [2] => [Microsoft][sql Server Native Client 10.0][sql Server]Invalid column name 'B7N4L15'. [message] => [Microsoft][sql Server Native Client 10.0][sql Server]Invalid column name 'B7N4L15'. ) ) FYI, B7N4L15 is the value being entered as $sedol. I'm pretty sure the problem is with the column name REF (SEDOL) No., but I've no idea how to contain the dodgy name. Unfortunately, I don't have the luxury of renaming the column, so I have to make do. Is there anything I can do to make this work? Cheers
  14. Hi Litebearer, Thanks for your suggestion however, I got the unix epoch time for all dates except the first...
  15. Hi CPD, It is adding 4 weeks every time. Every column should display 11 dates (so column 1 works perfectly), and column 2 should carry on where column 1 left off. It's this that is the problem, it isn't carrying on, it's starting again. Thanks
×
×
  • 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.