Jump to content

Problem Feeding Sql Data Into Jquery Ui Dialog Box


Icebergness

Recommended Posts

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
Share on other sites

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