Jump to content

Php in HTML 5 Canvass and JS


claro

Recommended Posts

Greetings!

 

I'm planning to place my result in a canvass, queries result are shown during debugging, but I dont know how to put it in php.

Is this possible?

 

<?php
include "include/z_db.php";
$query1 = mysql_query ("SELECT D.course_Id, COUNT(Status) as STAT FROM tbl_data AS D
					WHERE D.Status = 'Cleared' AND D.office_Id = 117
					GROUP BY course_Id") or die (mysql_error());
?>
<html>
<head>
<script type="application/javascript" language="javascript">
window.onload = draw; // Execute draw function when DOM is ready
function draw() {
    // Assign our canvas element to a variable 
    var canvas = document.getElementById("canvas1");
    // Create the HTML5 context object to enable draw methods
    var ctx = canvas.getContext("2d"); 
    // Assign font family and pixel size
    ctx.font = "9pt Arial";
    //fillText Parameters ("Text", X, Y); 


<?php 
while ($row = mysql_fetch_array ($query1))
{
$course =  $row['course_Id'];
$courses = mysql_query ("SELECT course_Title FROM tbl_course WHERE course_Id = '$course' ") or die (mysql_error());
while ($row2 = mysql_fetch_array ($courses))
	{
		$status = $row['STAT'];
		$course = $row2['course_Title'];
	    //fillText Parameters ("Text", X, Y); 		
		echo "ctx.fillText(".$course.", 10, 20); ";
		//fillStyle Parameters (r, g, b, alpha);
		echo "ctx.fillStyle = 'rgba(0,200,0,1)'";
		//fillRect Parameters (X, Y, width, height); 
		echo "ctx.fillRect (36, 10, ".$status.", 12);";
    	}
}
?>	
  }
</script>  
</head>  
<body>
<canvas id="canvas1" width="200" height="110"></canvas>
</body>  
</html>  

Link to comment
https://forums.phpfreaks.com/topic/249312-php-in-html-5-canvass-and-js/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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