Icebergness Posted November 6, 2012 Share Posted November 6, 2012 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 Link to comment https://forums.phpfreaks.com/topic/270355-problem-feeding-sql-data-into-jquery-ui-dialog-box/ Share on other sites More sharing options...
Icebergness Posted November 6, 2012 Author Share Posted November 6, 2012 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> Link to comment https://forums.phpfreaks.com/topic/270355-problem-feeding-sql-data-into-jquery-ui-dialog-box/#findComment-1390512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.