Jump to content

Icebergness

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by Icebergness

  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
  16. I'm trying to create a table that looks like this: 25/11/201128/09/201202/08/2013 23/12/201126/10/201230/08/2013 20/01/201223/11/201227/09/2013 17/02/201221/12/201225/10/2013 16/03/201218/01/201322/11/2013 13/04/201215/02/201320/12/2013 11/05/201215/03/201317/01/2014 08/06/201212/04/201314/02/2014 06/07/201210/05/201314/03/2014 03/08/201207/06/201311/04/2014 31/08/201205/07/201309/05/2014 Basically it formats the dates automatically every 4 weeks into 3 columns. So far, I have the following code: <?php $startDate = '2011-11-25'; $columns = 3; $number_of_dates = 33; // calculate number of rows per column $rows_per_column = ceil($number_of_dates / $columns); // make your table echo "<table>\n"; //here we changed the condition to $i < $rows for($i = 0; $i < $rows_per_column; $i++) { echo "<tr>\n"; //here will run another loop for the amount of columns for($j = 0; $j < $columns; $j++) { $weekOffset = $i * 4; $nextDate = strtotime("{$startDate} +{$weekOffset} weeks"); echo "<td width = '100'>" . date('d/m/y', $nextDate) . "</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; ?> Which creates the first column fine, but then repeats the same column two more times... 25/11/201125/11/201125/11/2011 23/12/201123/12/201123/12/2011 20/01/201220/01/201220/01/2012 17/02/201217/02/201217/02/2012 16/03/201216/03/201216/03/2012 13/04/201213/04/201213/04/2012 11/05/201211/05/201211/05/2012 08/06/201208/06/201208/06/2012 06/07/201206/07/201206/07/2012 03/08/201203/08/201203/08/2012 31/08/201231/08/201231/08/2012 I know that this means there is a problem with my loop resetting itself rather than continuing, but I'm not sure how to fix it. Please could someone point out my stupid mistake? Thanks
  17. Thank you very much tbare, that final script worked an absolute treat. It's easy to forget that PHP is averse to the British date format
  18. Hi, As the title says, I'm trying to get the last working day of the month (by this I mean excluding Saturday and Sunday). My thinking was that I basically need to this: If (day = Sat) { -1 day } elseif (day = Sun) { -2 days } else { keep it as it is } So far, all I have is the below to echo out the day of date("t/m/y"), however, all I'm getting is Thursday, whereas the last day of March is a Saturday <?php $lastdateofthemonth = date("t/m/y"); $lastworkingday = date('l', strtotime($lastdateofthemonth)); echo $lastworkingday; ?> Can anyone help, or point me in the way of where this may have been answered in the past? I've searched all over Google but can't find what I'm looking for. Thanks
  19. Oooh, the easy fixes are always the best. That worked perfectly. Thanks for the quick advice!
  20. Hi, I am trying to update two columns on one table from a form. The table is called pages, and there are three columns: id (auto-increments) name content When I try to update 'name' and 'content', I get the following error: The form simply calls the following script on submittal : <?php $name = $_POST[name]; $content = $_POST[content]; include ("../index_files/mysql_include.php"); $result = mysql_query("UPDATE pages SET name = '$name', content = '$content' WHERE id = $id"); if (!mysql_query($result, $connection)) { die('Error: ' . mysql_error()); } mysql_close($connection); ?> Can anyone see where I'm going wrong? I've tried several different variations of the code with no joy. I should point out that the above code does update MySQL successfully, but it keeps coming out with this error which I'd rather not have Thanks, Dave
  21. Sorry, I forgot to check this post as I've been working on other projects. I had previously looked at xpdf, but hadn't gotten the results I was looking for. I'll give it a try with Sphider and let you know how I get on. Thanks for the suggestion Dave
  22. this won't work, because for instance, '10.44.6.' does not equal '10.44.6.1'. You use something like strpos instead. Alternatively you can use regex to match it, if you want to match ranges. Hi guys, I went with the strpos idea which worked perfectly. I put this code in the header: <?php $ip = $_SERVER['REMOTE_ADDR']; $london = '10.44.'; $office = strpos($ip, $london); $blackpool_path = 'path'; $london_path = 'path' ?> And put this where the link would go: <a href="<?php if ($office === false) { echo $blackpool_path; } else { echo $london_path; }; ?>installer.exe">Link name</a> Many thanks for your help Dave
  23. Hi, I have a page on my Intranet which lists a bunch of install files (for example, Microsoft Office), which are stored in the same directory structure as the site itself. I also have a duplicate installs folder structure in another office, on their local server. I want to make it so that the link changes, depending on which office the user is in. To simplify: If (user is in London) display London link else display Blackpool link I've been trying to make it work via IP Address. The IP range in London is 10.44.6.* However, I can't make the script work with a wildcard (it works fine if I put a specific address in). The code I have so far is: <?php $ip=$_SERVER['REMOTE_ADDR']; if ($ip == '10.44.6.*') { ?><a href="link1.php">Click Here</a><?php } else { ?><a href="link2.php">Click Here</a><?php }; ?> I think it may be an obvious solution, but if some kind person could perhaps point out my mistakes? Thanks, Dave
  24. Hi, I currently have a 'Research' page on my intranet site. It works by displaying a list of files based on the date selected. The files are stored in a folder hierarchy on the same server, for example: 2012 <-Year --01 <-Month ----01 <-Day ----02 <-Day The folders contain a multitude of files that are dropped in by other members of staff, and 99% of the time consist of .msg, .doc and .pdf files. What I want to do is create a textbox which will allow the user to search through the files (as in the file contents, not just the file name). So far, the best thing I have found for this is the following code: <?php /** * powered by @cafewebmaster.com * free for private use * please support us with donations */ define("SLASH", stristr($_SERVER[sERVER_SOFTWARE], "win") ? "\\" : "/"); $path = ($_POST[path]) ? $_POST[path] : dirname(__FILE__) ; $q = $_POST[q]; function php_grep($q, $path){ $fp = opendir($path); while($f = readdir($fp)){ if( preg_match("#^\.+$#", $f) ) continue; // ignore symbolic links $file_full_path = $path.SLASH.$f; if(is_dir($file_full_path)) { $ret .= php_grep($q, $file_full_path); } else if( stristr(file_get_contents($file_full_path), $q) ) { $ret .= "$file_full_path\n"; } } return $ret; } if($q){ $results = php_grep($q, $path); } echo <<<HRD <pre > <form method=post> <input name=path size=100 value="$path" /> Path <input name=q size=100 value="$q" /> Query <input type=submit> </form> $results </pre > HRD; ?> This obviously uses GREP, which works well, albeit slow. However, it doesn't search through PDF's. I have contemplated several solutions, including finding a way to convert all the files in to text files or in to a mysql database, but I haven't found anything useful. I think the answer is going to be no, but I'm asking whether anybody knows, or has successfully implemented a similar system? Big big thanks in advance if you can help in any way! Dave
  25. Thank you very much for that, it's working now However, I now have another question - I want to split the list in to months, so that there is a list for January 2012, another list for December 2011 and so on, rather than one indigestible long list. This normally wouldn't be a problem, as I could just repeat the script and hard code the dates for the start and end of each month. However, if I do it for this month and in the future months, I would get the following output: 16/01/2012 17/01/2012 18/01/2012 19/01/2012 20/01/2012 I don't want any future dates to be shown, rather I would prefer for it to show up until yesterdays date (16/01/2012). Any ideas? Cheers, Dave
×
×
  • 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.