0

Anyone, help me here. Is my code possible? I need to assign the total number of records from the database query to the graph of javascript.

]<?php 
mysql_connect("localhost", "aaaa", "aaa") or die(mysql_error());
mysql_select_db("aaa") or die(mysql_error());
$result = mysql_query("SELECT * FROM table WHERE field ='1'") or die(mysql_error());  
while($row = mysql_fetch_array($result))
			{
				$id = $row['empId'];
						}
			

?>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="graph.js"></SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.2">
	
	var g = new Graph(400,200);
	
	g.scale = 1;
	<?php
	$resultCount = mysql_query("SELECT COUNT(*) FROM aa where bbb='1' AND ccc = '%egasg%'") or die(mysql_error()); 
	$count= mysql_result($resultCount,0,0);
	echo g.addRow($count,3,4,1);
	?>
	
	g.title = "haha";
	g.xLabel = "adhsashd";
	g.yLabel = "hasha";

	g.build();
</SCRIPT>

Edited by nav33n: Fixed [code] tags.

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by aneeka
0

You can do this:

g.scale = 1;
<?php
$resultCount = mysql_query("SELECT COUNT(*) FROM aa where bbb='1' AND ccc = '%egasg%'") or die(mysql_error());
$count= mysql_result($resultCount,0,0);
?>
g.addRow(<?php echo $count; ?>,3,4,1);
g.title = "haha";
0

It doesn't show any error, the graph is displayed, but it can't get the total number of record from the database.

0

In your query change ccc = '%egasg%'" to ccc LIKE '%egasg%'" . Other than that I can't tell what could be wrong with your query.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.