Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pulling results of SQL into Java

Status
Not open for further replies.

andyfresh

Technical User
Oct 4, 2005
33
GB
Hi,

I need some help on some simple java. Basically what I would like to do is to run a SQL script and then the results from that script to be passed into Java.

The code I currently have is:

Code:
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<script type="text/javascript" src="wz_jsgraphics.js"></script>
<script type="text/javascript" src="pie.js">
</script>

<div id="pieCanvas" style="overflow: auto; position:relative;height:350px;width:380px;"></div>
<input type="hidden" value="<? echo"$value"; ?>" name="value">

<? require_once ('../templates/mysql_connect.php');
$query = "SELECT sum(yes)as yes, sum(undecided)as undecided, sum(no)as no FROM ratings where CompanyID = 5";
$result = @mysql_query ($query);
if ($result){
while ($row =mysql_fetch_array($result, MYSQL_NUM)){
$yes = $row[0];
$undecided = $row[1];
$no = $row[2];

<script type="text/javascript">
var p = new pie();
p.add("yes",$yes);
p.add("undecided",$undecided);
p.add("no",$no);
p.render("pieCanvas", "Pie Graph")
</script>
}
mysql_free_result ($result);

}else{
echo'<p>the users could not be displayed</p><p>' . mysql_error() . '</p>';
}
mysql_close();

?>
</body>
</html>

Can any one give me some guidance on where this is going wrong?

Andy
 
1) this forum, and what you are asking questions about, is JavaScript, not Java. They are two different languages.
2) JavaScript is a client-side code (except in some cases of ASP). It runs on client machines, not on the server. Therefore, you will need to generate your JavaScript as output with PHP.

So, you'll need to echo your JavaScript out. Ask in the PHP Forum (forum434) for more details.



*cLFlaVA
----------------------------
[tt]somebody set up us the bomb![bomb][/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Hi,

cLFlaVA if absolutely right -you're in the wrong forum, andyfresh!

Having said that... have a glance at your javascript ... see it now? What's it doing in the PHP code? echo or print will fix your problem!

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top